C,
pasted
on Aug 30:
|
<?php
/**
* OnePress Child Theme Functions
*
*/
/**
* Enqueue child theme style
*/
add_action( 'wp_enqueue_scripts', 'onepress_child_enqueue_styles', 15 );
function onepress_child_enqueue_styles() {
wp_enqueue_style( 'onepress-child-style', get_stylesheet_directory_uri() . '/style.css' );
}
/**
* Hook to add custom section after about section
*
* @see wp-content/themes/onepress/template-frontpage.php
*/
/*
function add_my_custom_section(){
?>
<section id="my_section" class="my_section section-padding onepage-section">
<div class="container">
<div class="section-title-area">
<h5 class="section-subtitle"> My section subtitle</h5>
<h2 class="section-title"> My section title</h2>
</div>
<div class="row">
<!-- Your section content here, you can use bootstrap 4 elements :) -->
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
</div>
</div>
</section>
<?php
}
add_action( 'onepress_after_section_about', 'add_my_custom_section' );
*/
add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );
function my_show_extra_profile_fields( $user ) { ?>
<h3>Informazioni fiscali</h3>
<table class="form-table">
<tr>
<th><label for="cod_fisc_iva">Codice Fiscale/P.IVA</label></th>
<td>
<input type="text" name="cod_fisc_iva" id="cod_fisc_iva" value="<?php echo esc_attr( get_the_author_meta( 'cod_fisc_iva', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Inserisci il tuo codice fiscale o P.IVA</span>
</td>
</tr>
</table>
<?php }
add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );
function my_save_extra_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
/* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
update_usermeta( $user_id, 'twitter', $_POST['twitter'] );
}
//Aggiunta dei campi personalizzati al form di registrazione
add_action( 'register_form', 'adding_custom_registration_fields' );
function adding_custom_registration_fields( ) {
//lets make the field required so that i can show you how to validate it later;
$firstname = empty( $_POST['firstname'] ) ? '' : $_POST['firstname'];
$lastname = empty( $_POST['lastname'] ) ? '' : $_POST['lastname'];
$company = empty( $_POST['company'] ) ? '' : $_POST['company'];
$billing_address_1 = empty( $_POST['billing_address_1'] ) ? '' : $_POST['billing_address_1'];
$cod_fisc_iva = empty( $_POST['cod_fisc_iva'] ) ? '' : $_POST['cod_fisc_iva'];
?>
<div class="form-row form-row-wide">
<label for="reg_firstname"><?php _e( 'First Name', 'woocommerce' ) ?><span class="required">*</span></label>
<input type="text" class="input-text" name="firstname" id="reg_firstname" size="30" value="<?php echo esc_attr( $firstname ) ?>" />
</div>
<div class="form-row form-row-wide">
<label for="reg_lastname"><?php _e( 'Last Name', 'woocommerce' ) ?><span class="required">*</span></label>
<input type="text" class="input-text" name="lastname" id="reg_lastname" size="30" value="<?php echo esc_attr( $lastname ) ?>" />
</div>
<div class="form-row form-row-wide">
<label for="reg_company"><?php _e( 'Ragione Sociale', 'woocommerce' ) ?></label>
<input type="text" class="input-text" name="company" id="reg_company" size="30" value="<?php echo esc_attr( $company ) ?>" />
</div>
<div class="form-row form-row-wide">
<label for="cod_fisc_iva"><?php _e( 'Codice Fiscale/P.IVA', 'woocommerce' ) ?><span class="required">*</span></label>
<input type="text" class="input-text" name="cod_fisc_iva" id="cod_fisc_iva" size="30" value="<?php echo esc_attr( $cod_fisc_iva ) ?>" />
</div>
<div class="form-row form-row-wide">
<label for="reg_billing_address_1"><?php _e( 'Indirizzo di fatturazione', 'woocommerce' ) ?><span class="required">*</span></label>
<input type="text" class="input-text" name="billing_address_1" id="reg_billing_address_1" size="30" value="<?php echo esc_attr( $billing_address_1 ) ?>" />
</div>
<div class="form-row form-row-wide">
<span class="required">*</span></label>
<input type="checkbox" name="conditions" value=""/> Autorizzazione <a href="#">Trattamento Privacy</a>
</div><?php
}
//Validazione campi personalizzati
add_filter( 'woocommerce_registration_errors', 'registration_errors_validation' );
function registration_errors_validation( $reg_errors ) {
if ( empty( $_POST['firstname'] ) ) {
$reg_errors->add( 'empty required fields', __( 'Nome Obbligatorio', 'woocommerce' ) );
}
if ( empty( $_POST['lastname'] ) ) {
$reg_errors->add( 'empty required fields', __( 'Cognome Obbligatorio', 'woocommerce' ) );
}
if ( empty( $_POST['cod_fisc_iva'] ) ) {
$reg_errors->add( 'empty required fields', __( 'Codice Fiscale o P.IVA Obbligatori', 'woocommerce' ) );
}
if ( empty( $_POST['billing_address_1'] ) ) {
$reg_errors->add( 'empty required fields', __( 'Indirizzo di fatturazione Obbligatorio', 'woocommerce' ) );
}
if ( !isset( $_POST['conditions'] ) ) {
$reg_errors->add( 'empty required fields', __( 'Accettazione Privacy Obbligatoria', 'woocommerce' ) );
}
return $reg_errors;
}
//Aggiornamento campi dopo registrazione
add_action('woocommerce_created_customer','adding_extra_reg_fields');
function adding_extra_reg_fields($user_id) {
extract($_POST);
update_user_meta($user_id, 'first_name', $firstname);
update_user_meta($user_id, 'last_name', $lastname);
update_user_meta($user_id, 'billing_first_name', $firstname);
update_user_meta($user_id, 'shipping_first_name', $firstname);
update_user_meta($user_id, 'billing_last_name', $lastname);
update_user_meta($user_id, 'shipping_last_name', $lastname);
update_user_meta($user_id, 'billing_company', $company);
update_user_meta($user_id, 'shipping_company', $company);
update_user_meta($user_id, 'billing_address_1', $billing_address_1);
update_user_meta($user_id, 'cod_fisc_iva', $cod_fisc_iva);
}
/**
* To display additional field at My Account page
* Once member login: edit account
*/
add_action( 'woocommerce_edit_account_form', 'my_woocommerce_edit_account_form' );
function my_woocommerce_edit_account_form() {
$user_id = get_current_user_id();
$user = get_userdata( $user_id );
if ( !$user )
return;
$cod_fisc_iva = get_user_meta( $user_id, 'cod_fisc_iva', true );
?>
<fieldset>
<legend>Dati fiscali</legend>
<p class="form-row form-row-thirds">
<label for="cod_fisc_iva">Codice Fiscale/P.IVA<span class="required">*</label>
<input type="text" name="cod_fisc_iva" value="<?php echo esc_attr( $cod_fisc_iva ); ?>" class="input-text" required="required"/>
<br />
</p>
</fieldset>
<?php
} // end func
/**
* This is to save user input into database
* hook: woocommerce_save_account_details
*/
add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' );
function my_woocommerce_save_account_details( $user_id ) {
update_user_meta( $user_id, 'cod_fisc_iva', htmlentities( $_POST[ 'cod_fisc_iva' ] ) );
} // end func
|
Output:
|
Line 1: error: expected identifier or '(' before '<' token
Line 12: warning: character constant too long for its type
Line 34: warning: character constant too long for its type
Line 11: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'onepress_child_enqueue_styles'
Line 22: warning: character constant too long for its type
Line 79: warning: character constant too long for its type
Line 12: warning: character constant too long for its type
Line 40: error: expected declaration specifiers or '...' before '\x66696c65'
Line 33: warning: character constant too long for its type
Line 40: error: expected declaration specifiers or '...' before '\x656c6473'
Line 40: warning: data definition has no type or storage class
Line 12: warning: character constant too long for its type
Line 41: error: expected declaration specifiers or '...' before '\x66696c65'
Line 33: warning: character constant too long for its type
Line 41: error: expected declaration specifiers or '...' before '\x656c6473'
Line 41: warning: data definition has no type or storage class
Line 43: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'my_show_extra_profile_fields'
Line 12: warning: character constant too long for its type
Line 60: error: expected declaration specifiers or '...' before '\x64617465'
Line 39: warning: character constant too long for its type
Line 60: error: expected declaration specifiers or '...' before '\x656c6473'
Line 60: warning: data definition has no type or storage class
Line 12: warning: character constant too long for its type
Line 61: error: expected declaration specifiers or '...' before '\x64617465'
Line 40: warning: character constant too long for its type
Line 61: error: expected declaration specifiers or '...' before '\x656c6473'
Line 61: warning: data definition has no type or storage class
Line 63: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'my_save_extra_profile_fields'
Line 25: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 46: warning: character constant too long for its type
Line 12: warning: character constant too long for its type
Line 72: error: expected declaration specifiers or '...' before '\x666f726d'
Line 29: warning: character constant too long for its type
Line 72: error: expected declaration specifiers or '...' before '\x656c6473'
Line 72: warning: data definition has no type or storage class
Line 73: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'adding_custom_registration_fields'
Line 28: warning: character constant too long for its type
Line 45: error: empty character constant
Line 57: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 44: error: empty character constant
Line 56: warning: character constant too long for its type
Line 27: warning: character constant too long for its type
Line 42: error: empty character constant
Line 54: warning: character constant too long for its type
Line 43: warning: character constant too long for its type
Line 68: error: empty character constant
Line 80: warning: character constant too long for its type
Line 38: warning: character constant too long for its type
Line 58: error: empty character constant
Line 70: warning: character constant too long for its type
Line 39: warning: character constant too long for its type
Line 53: warning: character constant too long for its type
Line 38: warning: character constant too long for its type
Line 51: warning: character constant too long for its type
Line 37: warning: character constant too long for its type
Line 56: warning: character constant too long for its type
Line 38: warning: character constant too long for its type
Line 62: warning: character constant too long for its type
Line 49: warning: character constant too long for its type
Line 78: warning: character constant too long for its type
Line 12: warning: character constant too long for its type
Line 108: error: expected declaration specifiers or '...' before '\x726f7273'
Line 47: warning: character constant too long for its type
Line 108: error: expected declaration specifiers or '...' before '\x74696f6e'
Line 108: warning: data definition has no type or storage class
Line 109: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'registration_errors_validation'
Line 20: warning: character constant too long for its type
Line 20: warning: character constant too long for its type
Line 49: warning: character constant too long for its type
Line 70: warning: character constant too long for its type
Line 20: warning: character constant too long for its type
Line 20: warning: character constant too long for its type
Line 49: warning: character constant too long for its type
Line 73: warning: character constant too long for its type
Line 20: warning: character constant too long for its type
Line 20: warning: character constant too long for its type
Line 49: warning: character constant too long for its type
Line 87: warning: character constant too long for its type
Line 19: warning: character constant too long for its type
Line 22: warning: character constant too long for its type
Line 51: warning: character constant too long for its type
Line 93: warning: character constant too long for its type
Line 20: warning: character constant too long for its type
Line 22: warning: character constant too long for its type
Line 51: warning: character constant too long for its type
Line 88: warning: character constant too long for its type
Line 11: warning: character constant too long for its type
Line 129: error: expected declaration specifiers or '...' before '\x6f6d6572'
Line 42: warning: character constant too long for its type
Line 129: error: expected declaration specifiers or '...' before '\x656c6473'
Line 129: warning: data definition has no type or storage class
Line 130: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'adding_extra_reg_fields'
Line 28: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 28: warning: character constant too long for its type
Line 35: warning: character constant too long for its type
Line 35: warning: character constant too long for its type
Line 12: warning: character constant too long for its type
Line 147: error: expected declaration specifiers or '...' before '\x666f726d'
Line 45: warning: character constant too long for its type
Line 147: error: expected declaration specifiers or '...' before '\x666f726d'
Line 147: warning: data definition has no type or storage class
Line 149: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'my_woocommerce_edit_account_form'
Line 42: warning: character constant too long for its type
Line 12: warning: character constant too long for its type
Line 179: error: expected declaration specifiers or '...' before '\x61696c73'
Line 48: warning: character constant too long for its type
Line 179: error: expected declaration specifiers or '...' before '\x61696c73'
Line 179: warning: data definition has no type or storage class
Line 181: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'my_woocommerce_save_account_details'
Line 29: warning: character constant too long for its type
Line 67: warning: character constant too long for its type
|
|