settings_init();
$this->settings_save();
}
/**
* Init our settings.
*/
public function settings_init() {
add_settings_section( 'mp-timetable-permalinks', __( 'Timetable Permalinks', 'mp-timetable' ), array( $this, 'settings' ), 'permalink' );
add_settings_field(
'timetable_column_slug',
__( 'Column base', 'mp-timetable' ),
array( $this, 'timetable_column_slug_input' ),
'permalink',
'mp-timetable-permalinks'
);
add_settings_field(
'timetable_event_slug',
__( 'Event base', 'mp-timetable' ),
array( $this, 'timetable_event_slug_input' ),
'permalink',
'mp-timetable-permalinks'
);
add_settings_field(
'timetable_event_category_slug',
__( 'Event Category base', 'mp-timetable' ),
array( $this, 'timetable_event_category_slug_input' ),
'permalink',
'mp-timetable-permalinks'
);
add_settings_field(
'timetable_event_tag_slug',
__( 'Event Tag base', 'mp-timetable' ),
array( $this, 'timetable_event_tag_slug_input' ),
'permalink',
'mp-timetable-permalinks'
);
$this->permalinks = Core::get_instance()->get_permalink_structure();
}
/**
* Show a Column slug input box.
*/
public function timetable_column_slug_input() {
?>
sanitize_permalink( wp_unslash( $_POST['timetable_column_slug'] ) ); // WPCS: input var ok, sanitization ok.
$permalinks['event_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_slug'] ) ); // WPCS: input var ok, sanitization ok.
$permalinks['event_category_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_category_slug'] ) ); // WPCS: input var ok, sanitization ok.
$permalinks['event_tag_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_tag_slug'] ) ); // WPCS: input var ok, sanitization ok.
update_option( 'mp_timetable_permalinks', $permalinks );
}
}
private function sanitize_permalink( $value ) {
$value = esc_url_raw( trim( $value ) );
$value = str_replace( 'http://', '', $value );
return untrailingslashit( $value );
}
}