'; $site = 'options-general.php?page=teachpress/settings.php'; // Tab selector $tab_list = ['general', 'publication_data', 'publication_templates', 'db_status' ]; $tab_input = isset( $_GET['tab'] ) ? htmlspecialchars($_GET['tab']) : 'general'; $tab = ( in_array($tab_input, $tab_list) ) ? $tab_input : ''; // update dababase if ( isset($_GET['up']) ) { TP_Settings_Page::update_database($site); } // sync database if ( isset($_GET['sync']) ) { $sync = intval($_GET['sync']); if ( $sync === 1 ) { tp_db_sync('authors'); TP_Settings_Page::update_database($site, false); } if ( $sync === 2 ) { tp_db_sync('stud_meta'); } } // install database if ( isset($_GET['ins']) ) { tp_install(); } // delete database if ( isset( $_GET['drop_tp'] ) || isset( $_POST['drop_tp_ok'] ) ) { TP_Settings_Page::delete_database(); } // change general options if ( isset( $_POST['einstellungen'] ) ) { self::check_nonce_field(); TP_Settings_Page::change_general_options(); } // delete settings if ( isset( $_GET['delete'] ) ) { self::check_nonce_url(); TP_Options::delete_option($_GET['delete']); get_tp_message(esc_html__('Deleted', 'teachpress')); } // Delete data field if ( isset( $_GET['delete_field'] ) || isset( $_GET['delete_field_ok'] ) ) { self::check_nonce_url(); TP_Settings_Page::delete_meta_fields($tab); } // add meta field options if ( isset($_POST['add_field']) ) { self::check_nonce_field(); $table = 'teachpress_pub'; TP_Settings_Page::add_meta_fields($table); } // test if database is installed TP_Admin::database_test(); TP_HTML::line( '
 ) . ')
 ) . ')
' . get_tp_option('db-version') . ' "Lemon Tart"
Website | teachPress on GitHub | Dokumentation | Changelog
©2008-2025 by Michael Winkler | License: GPLv2 or later
'; TP_HTML::line( '
' ); } /** * Returns the select for for user role field * @param string $type * @access private * @since 5.0.0 */ private static function get_user_role_form ($type){ $title = ( $type === 'userrole_publications' ) ? esc_html__('Backend access for publication module','teachpress') : esc_html__('Backend access for course module','teachpress'); $cap = ( $type === 'userrole_publications' ) ? 'use_teachpress' : 'use_teachpress_courses'; TP_HTML::line( '| ' . esc_html__('teachPress version','teachpress') . ' | '; TP_HTML::line( '' . get_tp_option('db-version') . ' | ' ); echo ''; echo ''; echo ' |
|---|---|---|
| '; echo ' | '; echo ''; echo ' | '; echo '' . esc_html__('Select which style sheet you will use. teachpress_front.css is the teachPress default style. If you have created your own style in the default style sheet of your theme, you can activate this here.','teachpress') . ' | '; echo '
' . esc_html__('Related content','teachpress') . ' | ';
echo '||
| ' . esc_html__('Type','teachpress') . ' | '; echo ''; TP_Settings_Page::get_rel_page_form('rel_page_publications'); echo ' | '; echo '' . esc_html__('If you create a publication you can define a link to related content. It is kind of a "more information link", which helps you to connect a course/publication with a page. If you want to use custom post types instead of pages, so you can set it here.','teachpress') . ' | '; echo '
| ' . esc_html__('Default category for related content','teachpress') . ' | '; echo ''; wp_dropdown_categories( [ 'hide_empty' => 0, 'name' => 'rel_content_category', 'orderby' => 'name', 'selected' => get_tp_option('rel_content_category'), 'hierarchical' => true, 'show_option_none' => esc_html__('none','teachpress') ] ); echo ' | '; echo '' . esc_html__('Used if the related content type for publicaitons is set on','teachpress') . ': ' . esc_html__('Posts') . ' | '; echo '
| ' . esc_html__('Automatic related content','teachpress') . ' | '; TP_HTML::line( '' . TP_Admin::get_checkbox('rel_content_auto', esc_html__('Create an automatic related content with every new publication','teachpress'), get_tp_option('rel_content_auto')) . ' | ' ); echo '|
| ' . esc_html__('Template for related content','teachpress') . ' | '; TP_HTML::line( '' ); echo ' | |
' . esc_html__('Import / Export','teachpress') . ' | ';
echo '||
| ' . esc_html__('BibTeX special chars','teachpress') . ' | '; TP_HTML::line( '' . TP_Admin::get_checkbox('convert_bibtex', esc_html__('Try to convert utf-8 chars into BibTeX compatible ASCII strings','teachpress'), get_tp_option('convert_bibtex')) . ' | ' ); echo '|
| ' . esc_html__('Update existing publications','teachpress') . ' | '; TP_HTML::line( '' . TP_Admin::get_checkbox('import_overwrite', esc_html__('Allow optional updating for publication import','teachpress'), get_tp_option('import_overwrite')) . ' | ' ); echo '|
' . esc_html__('RSS','teachpress') . ' | ';
echo '||
| ' . esc_html__('RSS feed addresses','teachpress') . ' | '; TP_HTML::line( '' . esc_html__('For all publications:','teachpress') . ' ' . esc_html__('Example for publications of a single user (id = WordPress user-ID):','teachpress') . ' ' . esc_html__('Example for publications of a single tag (tag = tag-id):','teachpress') . ' | ' );
echo '|
' . esc_html__('Bibliography style','teachpress') . ' | ';
echo '||
| ' . esc_html__('Repeated citations','teachpress') . ' | '; TP_HTML::line( '' . TP_Admin::get_checkbox('ref_grouped', esc_html__('Cite every reference only once','teachpress'), get_tp_option('ref_grouped')) . ' | ' ); echo '|
' . esc_html__('Misc','teachpress') . ' | ';
echo '||
| ' . esc_html__('Database','teachpress') . ' | '; echo ''; TP_HTML::line( '' . esc_html__('Index status','teachpress') . '' ); echo ' | '; echo '|
| ' . esc_html__('Uninstalling','teachpress') . ' | '; echo ''; TP_HTML::line( '' . esc_html__('Remove teachPress from database','teachpress') . '' ); echo ' | '; echo '|
| ' . esc_html__('Field name','teachpress') . ' | '; echo '' . esc_html__('Properties','teachpress') . ' | '; echo '
|---|---|
| ' . $field->variable . ' | ' );
if ( isset( $data['title'] ) ) {
TP_HTML::line( 'Label: ' . stripslashes($data['title']) . ' ' ); } if ( isset( $data['type'] ) ) { TP_HTML::line( 'Type: ' . stripslashes($data['type']) . ' ' );} if ( isset( $data['visibility'] ) ) { TP_HTML::line( 'Visibility: ' . stripslashes($data['visibility']) . ' ' ); } if ( isset( $data['min'] ) ) { TP_HTML::line( 'Min: ' . stripslashes($data['min']) . ' ' ); } if ( isset( $data['max'] ) ) { TP_HTML::line( 'Max: ' . stripslashes($data['max']) . ' ' ); } if ( isset( $data['step'] ) ) { TP_HTML::line( 'Step: ' . stripslashes($data['step']) . ' ' ); } if ( isset( $data['required'] ) ) { TP_HTML::line( 'Required: ' . stripslashes($data['required']) . '' ); } echo ' | ';
echo '
| '; TP_HTML::line( '' . esc_html__('Add new','teachpress') . '' ); echo ' | '; echo '|
| ' . esc_html__('Name') . ' | '; echo '' . esc_html__('Key') . ' | '; echo '' . esc_html__('Description') . ' | '; echo '
|---|
' . esc_html__('Version', 'teachpress') . ' ' . esc_html($settings['version']) . ' | ' . esc_html__('by', 'teachpress') . ' ' . esc_html($settings['author']) . '
| ' . esc_html__('Key_name','teachpress') . ' | '; echo '' . esc_html__('Type','teachpress') . ' | '; echo '' . esc_html__('Unique','teachpress') . ' | '; echo '' . esc_html__('Packed','teachpress') . ' | '; echo '' . esc_html__('Column','teachpress') . ' | '; echo '' . esc_html__('Cardinality','teachpress') . ' | '; echo '' . esc_html__('Collation','teachpress') . ' | '; echo 'NULL | '; echo '' . esc_html__('Seq index','teachpress') . ' | '; echo '
|---|---|---|---|---|---|---|---|---|
| ' . esc_html($row['Key_name']) . ' | '; echo '' . esc_html($row['Index_type']) . ' | '; echo '' . esc_html($unique) . ' | '; echo '' . esc_html($row['Packed']) . ' | '; echo '' . esc_html($row['Column_name']) . ' | '; echo '' . esc_html($row['Cardinality']) . ' | '; echo '' . esc_html($row['Collation']) . ' | '; echo '' . esc_html($n) . ''; echo ' | ' . esc_html($row['Seq_in_index']) . ' | '; echo '
' . esc_html__('Do you really want to delete the selected meta field?','teachpress') . '
' . ''. esc_html__('OK') . ' '. esc_html__('Cancel') . ''; get_tp_message($message,'orange'); } if ( isset($_GET['delete_field_ok']) ) { $option = TP_Options::get_option_by_id($_GET['delete_field_ok']); $options = get_tp_options($option['variable'], "`setting_id` DESC", ARRAY_A); foreach ( $options as $row ) { TP_Options::delete_option($row['setting_id']); } TP_Options::delete_option($_GET['delete_field_ok']); get_tp_message( esc_html__('Field deleted','teachpress') ); } } /** * Handles changing of general options * @access private * @since 5.0.0 */ private static function change_general_options () { // Just for administrators if ( !current_user_can( 'manage_options' ) ) { return; } $option_semester = isset( $_POST['semester'] ) ? htmlspecialchars($_POST['semester']) : ''; $option_rel_page_publications = isset( $_POST['rel_page_publications'] ) ? htmlspecialchars($_POST['rel_page_publications']) : ''; $option_stylesheet = isset( $_POST['stylesheet'] ) ? intval($_POST['stylesheet']) : ''; $option_userrole_publications = isset( $_POST['userrole_publications'] ) ? $_POST['userrole_publications'] : ''; $checkbox_convert_bibtex = isset( $_POST['convert_bibtex'] ) ? 1 : ''; $checkbox_import_overwrite = isset( $_POST['import_overwrite'] ) ? 1 : ''; $checkbox_rel_content_auto = isset( $_POST['rel_content_auto'] ) ? 1 : ''; $checkbox_ref_grouped = isset( $_POST['ref_grouped'] ) ? 1 : ''; TP_Options::change_option('sem', $option_semester); TP_Options::change_option('rel_page_publications', $option_rel_page_publications); TP_Options::change_option('stylesheet', $option_stylesheet); TP_Options::change_option('convert_bibtex', $checkbox_convert_bibtex, 'checkbox'); TP_Options::change_option('import_overwrite', $checkbox_import_overwrite, 'checkbox'); TP_Options::change_option('rel_content_auto', $checkbox_rel_content_auto, 'checkbox'); TP_Options::change_option('rel_content_template', $_POST['rel_content_template']); TP_Options::change_option('rel_content_category', $_POST['rel_content_category']); tp_update_userrole($option_userrole_publications, 'use_teachpress'); TP_Options::change_option('ref_grouped', $checkbox_ref_grouped, 'checkbox'); get_tp_message( esc_html__('Settings are changed. Please note that access changes are visible, until you have reloaded this page a second time.','teachpress') ); } /** * Handles start of database updates * @param string $site The current URL * @param boolean $with_structure_change Update database structure (true) or not (false), Default is true * @access private * @since 5.0.0 */ private static function update_database ($site, $with_structure_change = true) { if ( $with_structure_change === true ) { tp_db_update(); } $check_stud_meta = TP_Update::check_table_stud_meta(); $check_authors = TP_Update::check_table_authors(); if ( $check_authors === false && $check_stud_meta === false ) { return; } $sync = ( $check_authors === true ) ? 1 : 2; $table = ( $check_authors === true ) ? 'teachpress_authors' : 'teachpress_stud_meta'; $message = 'TABLE ' . $table . ': ' . esc_html__('teachPress wants to fill up the new database. This can take some time.','teachpress') . ' ' . esc_html__('Continue','teachpress') . ''; get_tp_message($message, 'orange'); } /** * Handles database deletion * @access private * @since 5.0.0 */ private static function delete_database () { // Just for administrators if ( !current_user_can( 'manage_options' ) ) { return; } // Form for delete database question if ( isset($_GET['drop_tp']) && ! isset($_POST['drop_tp_ok']) ) { echo ''; } // Delete if wp_nonce is ok if ( isset($_POST['drop_tp_ok']) ) { if ( ! wp_verify_nonce( $_POST['tp_nonce_del_db'], 'verify_teachpress_del_db' ) ) { wp_die('teachPress error: This request could not be verified!'); exit; } tp_uninstall(); get_tp_message( esc_html__('Database uninstalled','teachpress') ); } } /** * Checks the nonce field of the form. If the check fails wp_die() will be executed */ private static function check_nonce_field () { if ( ! isset( $_POST['tp_nonce'] ) || ! wp_verify_nonce( $_POST['tp_nonce'], 'verify_teachpress_settings' ) ) { wp_die('teachPress error: This request could not be verified!'); exit; } } /** * Checks the nonce field of an url. If the check fails wp_die() will be executed */ private static function check_nonce_url () { if ( ! isset( $_GET['tp_nonce'] ) || ! wp_verify_nonce( $_GET['tp_nonce'], 'verify_teachpress_settings' ) ) { wp_die('teachPress error: This request could not be verified!'); exit; } } }