PHP 8.2.31
Preview: class-permalinks.php Size: 4.13 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/mp-timetable/classes/class-permalinks.php

<?php

namespace mp_timetable\plugin_core\classes;

class Permalinks {

	/**
	 * Permalink settings.
	 *
	 * @var array
	 */
	private $permalinks = array();

	/**
	 * Hook in tabs.
	 */
	public function __construct() {
		$this->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() {
		?>
		<input name="timetable_column_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['column_base'] ); ?>" placeholder="timetable/column" />
		<?php
	}

	/**
	 * Show an Event slug input box.
	 */
	public function timetable_event_slug_input() {
		?>
		<input name="timetable_event_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_base'] ); ?>" placeholder="timetable/event" />
		<?php
	}
	
	/**
	 * Show an Event Category slug input box.
	 */
	public function timetable_event_category_slug_input() {
		?>
		<input name="timetable_event_category_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_category_base'] ); ?>" placeholder="timetable/category" />
		<?php
	}

	/**
	 * Show an Event Tag slug input box.
	 */
	public function timetable_event_tag_slug_input() {
		?>
		<input name="timetable_event_tag_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_tag_base'] ); ?>" placeholder="timetable/tag" />
		<?php
	}

	/**
	 * Show the settings.
	 */
	public function settings() {
		wp_nonce_field( 'timetable-permalinks', 'timetable-permalinks-nonce' );
	}

	/**
	 * Save the settings.
	 */
	public function settings_save() {
		if ( ! is_admin() ) {
			return;
		}

		// We need to save the options ourselves; settings api does not trigger save for the permalinks page.
		if ( isset( $_POST['permalink_structure'],
					$_POST['timetable-permalinks-nonce'],
					$_POST['timetable_column_slug'],
					$_POST['timetable_event_slug'],
					$_POST['timetable_event_category_slug'],
					$_POST['timetable_event_tag_slug']
				) && wp_verify_nonce( sanitize_key( $_POST['timetable-permalinks-nonce'] ), 'timetable-permalinks' )
		) { // WPCS: input var ok, sanitization ok.

			$permalinks = (array) get_option( 'mp_timetable_permalinks', array() );

			$permalinks['column_base']			= $this->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 );
	}
}

Directory Contents

Dirs: 6 × Files: 12

Name Size Perms Modified Actions
blocks DIR
- drwxr-xr-x 2026-05-26 02:58:54
Edit Download
- drwxr-xr-x 2026-05-26 02:58:54
Edit Download
libs DIR
- drwxr-xr-x 2026-05-26 02:58:54
Edit Download
models DIR
- drwxr-xr-x 2026-05-26 02:58:54
Edit Download
modules DIR
- drwxr-xr-x 2026-05-26 02:58:54
Edit Download
widgets DIR
- drwxr-xr-x 2026-05-26 02:58:54
Edit Download
724 B lrw-r--r-- 2022-11-14 19:39:38
Edit Download
22.40 KB lrw-r--r-- 2026-05-25 23:22:48
Edit Download
11.84 KB lrw-r--r-- 2026-05-25 23:22:48
Edit Download
713 B lrw-r--r-- 2022-11-14 19:39:38
Edit Download
356 B lrw-r--r-- 2022-11-14 19:39:38
Edit Download
8.16 KB lrw-r--r-- 2024-02-13 00:39:10
Edit Download
4.13 KB lrw-r--r-- 2022-11-14 19:39:38
Edit Download
5.54 KB lrw-r--r-- 2022-11-14 19:39:38
Edit Download
13.40 KB lrw-r--r-- 2024-02-28 20:54:34
Edit Download
1.61 KB lrw-r--r-- 2024-02-13 00:39:10
Edit Download
5.74 KB lrw-r--r-- 2024-02-13 00:39:10
Edit Download
630 B lrw-r--r-- 2023-01-31 01:14:44
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).