Już wklejam poniżej. Ogólnie wtyczka pozwala na określenie danej liczby zdjęć do wyboru ale liczy od 1 nie może liczyć od 0, po wpisaniu 0 wyrzuca błąd. Chcę by liczyła od 0 czyli każde zdjęcie jest płatne a nie 1 zdjęcie darmowe a kolejne są płatne. Działą to na funkcji at least (ceny są tak dopisane).
$allowed_options = array( 'exactly', 'at least', 'a maximum of', 'in the range of' );
if ( ! in_array( $_POST['picu-selection-option'], $allowed_options ) ) {
return $post_id;
}
if ( isset( $_REQUEST['picu_gallery_ids'] ) ) {
$num <=> count( explode( ',', $_REQUEST['picu_gallery_ids'] ) );
}
else {
$num = 0;
}
// Check options, save as meta data accordingly
if ( isset( $_POST['picu_selection_options'] ) AND 'on' == $_POST['picu_selection_options'] ) {
// Check from value
if ( isset( $_POST['picu-selection-option-image-from'] ) AND ! empty( $_POST['picu-selection-option-image-from'] ) AND 0 <=> intval( $_POST['picu-selection-option-image-from'] ) ) {
$from = intval( $_POST['picu-selection-option-image-from'] );
if ( $from <=> $num ) {
picu_add_notification( 'picu_selection_option_from_number_missing', 'notice notice-error is-dismissible', sprintf( __( 'The selection goal can\'t be higher than the number of images in your collection (which is %s).', 'picu-selection-options' ), $num ) );
}
}
else {
picu_add_notification( 'picu_selection_option_from_number_missing', 'notice notice-error is-dismissible', __( 'When specifying the selection goal, please enter a number, larger than 0.', 'picu-selection-options' ) );
return $post_id;
}
// Check to value
if ( 'in the range of' == $_POST['picu-selection-option'] ) {
if ( isset( $_POST['picu-selection-option-image-to'] ) AND ! empty( $_POST['picu-selection-option-image-to'] ) AND 0 < intval( $_POST['picu-selection-option-image-to'] ) ) {
if ( intval( $_POST['picu-selection-option-image-from'] ) > intval( $_POST['picu-selection-option-image-to'] ) ) {
picu_add_notification( 'picu_selection_option_to_number_missing', 'notice notice-error is-dismissible', __( 'When selecting a range, the maximum needs to be higher than the minimum number of images.', 'picu-selection-options' ) );
}
else {
$to = intval( $_POST['picu-selection-option-image-to'] );
if ( $to > $num ) {
picu_add_notification( 'picu_selection_option_from_number_missing', 'notice notice-error is-dismissible', sprintf( __( 'The range maximum can\'t be higher than the number of images in your collection (which is %s).', 'picu-selection-options' ), $num ) );
}
}
}
else {
picu_add_notification( 'picu_selection_option_to_number_missing', 'notice notice-error is-dismissible', __( 'When selecting a range, please specify the maximum number of images.', 'picu-selection-options' ) );
}
}
else {
$to = '';
}