Last active
August 3, 2016 18:15
-
-
Save altuno/b98435eb7ccd19bec2283cff8500f448 to your computer and use it in GitHub Desktop.
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: Site plugin for genevaphotoclub.com | |
Description: Site specific code for genevaphotoclub.com | |
*/ | |
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */ | |
//* Allow state or province field to be a text field and make it optional | |
add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__state_field', 'billing_locale_text_field', 10, 1 ); | |
//add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__country_field', 'billing_locale_text_field', 10, 1 ); | |
function billing_locale_text_field( $original_field ) { | |
return new EE_Text_Input( array( 'required' => false, 'html_class' => 'ee-billing-qstn')); | |
} | |
function ee_populate_from_attendee_information_or_use_default( $autofill_data, $attendee ) { | |
if( $attendee instanceof EE_Attendee) { | |
if( $attendee->state_ID() ) { | |
$autofill_data[ 'state' ] = $attendee->state_name(); | |
} else { | |
$autofill_data[ 'state' ] = ''; | |
} | |
if( $attendee->country_ID() ) { | |
$autofill_data[ 'country' ] = $attendee->country_name(); | |
} else { | |
$autofill_data[ 'country' ] = 'CH'; | |
} | |
} | |
return $autofill_data; | |
} | |
add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', 'ee_populate_from_attendee_information_or_use_default', 10, 2 ); | |
// Register Now button text | |
function ee_register_now_button() { | |
return 'Register · S\'inscrire'; | |
} | |
add_filter ('FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', 'ee_register_now_button'); | |
// Finalize Registration button text | |
function ee_modify_button_text( $submit_button_text, EE_Checkout $checkout ) { | |
if ( ! $checkout instanceof EE_Checkout || ! $checkout->current_step instanceof EE_SPCO_Reg_Step || ! $checkout->next_step instanceof EE_SPCO_Reg_Step ) { | |
return $submit_button_text; | |
} | |
if ( $checkout->next_step->slug() == 'finalize_registration' ) { | |
$submit_button_text = 'Finalize registration · Finaliser l\'inscription'; | |
} | |
return $submit_button_text; | |
} | |
add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_modify_button_text', 10, 2); | |
// promotion button text | |
function ee_modify_promotions_button_text() { | |
return 'Submit Promotion Code · Soumettre le code de Promotion'; | |
} | |
add_filter( 'FHEE__EED_Promotions___add_promotions_form_inputs__ee_promotion_code_submit__default', 'ee_modify_promotions_button_text' ); | |
// Proceed to Payment Options text | |
function ee_proceed_to_button( $submit_button_text, EE_Checkout $checkout ) { | |
if ( ! $checkout instanceof EE_Checkout || ! $checkout->current_step instanceof EE_SPCO_Reg_Step || ! $checkout->next_step instanceof EE_SPCO_Reg_Step ) { | |
return $submit_button_text; | |
} | |
if ( $checkout->next_step->slug() == 'payment_options' ) { | |
$submit_button_text = 'Proceed to Payment · Procéder au Paiement'; | |
} | |
return $submit_button_text; | |
} | |
add_filter ( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_proceed_to_button', 10, 2 ); | |
// general text strings | |
function ee_general_filter_gettext( $translated, $original, $domain ) { | |
// This is an array of original strings | |
// and what they should be replaced with | |
$strings = array( | |
'Please Select Your Method of Payment' => 'Please Select Your Method of Payment · Merci de sélectionner votre mode de règlement', | |
'Important information regarding your payment' => '', | |
'First Name' => 'First name · Prénom', | |
'Last Name' => 'Last name · Nom de famille', | |
'Personal Information' => 'Personal Information · Vos données personnelles', | |
'Registrations:' => 'Number of Registrations · Nombre d\'inscriptions', | |
'Name and Description' => 'Course Name · Nom de Cours:', | |
'Price' => 'Price · Prix', | |
'Qty' => 'Qty · Qté', | |
'Total' => 'Total', | |
'Line Item' => '', | |
'Address' => 'Address · Adresse', | |
'City' => 'City · Ville', | |
'Country' => 'Country · Pays', | |
'Zip' => 'Postal Code · Code Postale', | |
'Phone' => 'Phone · Téléphone', | |
// Add some more strings here | |
); | |
// See if the current string is in the $strings array | |
// If so, replace its translation | |
if ( isset( $strings[$original] ) ) { | |
// This accomplishes the same thing as __() | |
// but without running it through the filter again | |
$translations = get_translations_for_domain( $domain ); | |
$translated = $translations->translate( $strings[$original] ); | |
} | |
return $translated; | |
} | |
add_filter( 'gettext', 'ee_general_filter_gettext', 10, 3 ); | |
//* Add instructor name to the CSV Download | |
add_filter( 'FHEE__EE_Export__report_registrations__reg_csv_array', 'espresso_add_author_to_report', 10, 2); | |
function espresso_add_author_to_report( $reg_csv_array, $reg_row ) { | |
$event_id = $reg_row['Registration.EVT_ID']; | |
$event = EEM_Event::instance()->get_one_by_ID( $event_id ); | |
if ( $event instanceof EE_Event ) { | |
$post_author = get_post_field( 'post_author', $event_id ); | |
$author_info = get_userdata( $post_author ); | |
$reg_csv_array['Author'] = $author_info->last_name . ", " . $author_info->first_name; | |
} | |
return $reg_csv_array; | |
} | |
//* Disable email match forced login - EE4 WP User Integration | |
add_filter( 'EED_WP_Users_SPCO__verify_user_access__perform_email_user_match_check', 'jf_ee_wp_users_remove_email_user_match_check' ); | |
function jf_ee_wp_users_remove_email_user_match_check() { | |
if ( ! is_user_logged_in() ) { | |
return false; | |
} else { | |
return true; | |
} | |
} | |
/* Stop Adding Functions */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment