Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Pebblo / tw_ee_default_post_content.php
Created December 31, 2019 11:54
Example of how to add a default description to EE events.
<?php // Please do not add the opening PHP tag if you already have one
add_filter('default_content', 'tw_ee_default_post_content', 2, 10);
function tw_ee_default_post_content($post_content, $post){
if(get_post_type($post) == 'espresso_events'){
$post_content = 'Add your default EE post content here';
}
return $post_content;
}
@Pebblo
Pebblo / example.php
Created March 28, 2019 15:38
Example of how to alter the links within the 'attention box' on the EE thank you page to open in a new window.
<?php //Please do not include the opening PHP tag if you already have one
function ee_add_target_blank_to_thank_you_page_links() {
wp_add_inline_script(
'thank_you_page',
'jQuery( document ).ready(function($) {
$("#espresso-thank-you-page-overview-dv .ee-attention a").each(function() {
$(this).attr("target","_blank");
});
});'
@joshfeck
joshfeck / gettext_with_context_example.php
Created August 3, 2018 16:44
Translate strings with context. Important: use this filter function only for i18n-ready strings that are wrapped in esc_html_x() or similar.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'gettext_with_context',
'mycustom_filter_gettext_with_context',
10,
4
);
function mycustom_filter_gettext_with_context(
@tomaskavalek
tomaskavalek / wordpress_custom_archive_title.php
Last active September 5, 2018 01:57
Wordpress – Customize archive page title for selected post type
<?php
/**
* @param $title
* @return array
*/
function archive_titles($title): array
{
global $post;
if ( ! isset($post->post_type)) {
@Pebblo
Pebblo / example.php
Created October 23, 2017 13:19
Remove the promotion code filed if none of the events within the cart have a promotion available.
<?php //Please do not include the opening PHP tag if you already have one
function tw_remove_promo_input( $before_payment_options) {
//If the promotions add-on is not active we don't need any of this to run.
if( class_exists('EEM_Promotion') ) {
$checkout = EE_Registry::instance()->SSN->checkout();
if ( $checkout instanceof EE_Checkout ) {
$transaction = $checkout->transaction;
if ( $transaction instanceof EE_Transaction ) {
//Create an array to hold the event ID's.
@Pebblo
Pebblo / all-events.php
Last active May 25, 2018 16:57
Example of how to hide the 'Personal Information' email question for all additional registrants and then copy the email address set by the Primary Registrant to all other email fields.
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_copy_primary_email_to_all() {
wp_add_inline_style(
'single_page_checkout',
'.spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email-input-dv, .spco-attendee-panel-dv:not(:first-of-type) .ee-reg-qstn-email {
display: none;
}'
);
@Pebblo
Pebblo / functions.php
Last active December 5, 2016 22:42
An example of how to remove scripts from the EE Event/Venue pages. Currently this removes the Januas 'cmb-scripts' script file.
<?php //Do not include the opneing PHP tag if you already have one.
//This functions can be used to remove scripts loaded by other plugins (or the sites theme) on EE Event/Venue pages.
function tw_ee_remove_scripts_from_event_editor( $hook_suffux ){
$page = isset( $_GET['page'] ) ? $_GET['page'] : '';
$action = isset( $_GET['action'] ) ? $_GET['action'] : '';
if ( ( $hook_suffux == 'post.php' || $hook_suffux == 'post-new.php' ) && ( $page == 'espresso_events' || $page == 'espresso_venues' ) && ( $action == 'edit' || $action == 'create_new' ) ) {
@Pebblo
Pebblo / ee_taxonomy_body_class.php
Last active April 18, 2018 21:44 — forked from joshfeck/ee_taxonomy_body_class.php
Add event's category slug to registration checkout and thank you page's body class
<?php //Please do not add the opening PHP tag if you already have one
// add category slug to registration checkout and thank you page's body class
add_filter( 'body_class', 'jf_ee_return_event_tax_term_on_spco' );
function jf_ee_return_event_tax_term_on_spco( $classes ){
// get out if this isn't the reg checkout page
if (! is_page( 'thank-you' ) && ! is_page( 'registration-checkout' ) ){
return $classes;
}
@Pebblo
Pebblo / ee_display_download_tickets.php
Created September 18, 2015 11:35
Add a 'Download your tickets' button to the EE4 thank you page. The hook in use adds the button above the overview, just under the confirmation order section. You will likely need to apply your own styles, possibly a container div and apply styles to that depending on how you want this to be displayed.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function ee_display_download_tickets( $transaction ) {
if ( $transaction instanceof EE_Transaction ) {
$primary_reg = $transaction->primary_registration();
if ( $primary_reg->is_approved() ) {
@Pebblo
Pebblo / ee-event-roles.php
Last active December 12, 2019 22:24
This plugin adds 2 custom roles you can assign to users to provide access to Event Espresso. An Event Organizer should have capabilities to read, edit and publish their own events, they can also view their own events registrations/transactions and should not have access to others events, registration, transactions. Events Managers can view, edit…
<?php
/*
Plugin Name: EE Event Roles Plugin
Description: Creates the 'Event Organiser' and 'Events Maneger' roles for use within Event Espresso.
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from comment and trackback spam</strong>. It keeps your site protected from spam even while you sleep. To get started: 1) Click the "Activate" link to the left of this description, 2) <a href="http://akismet.com/get/">Sign up for an Akismet API key</a>, and 3) Go to your Akismet configuration page, and save your API key.
Version: 1.0.0
*/
function add_roles_on_plugin_activation() {