File "class-sp-settings-text.php"

Full Path: /home/londdqdw/public_html/06/wp-content/plugins/sportspress/includes/admin/settings/class-sp-settings-text.php
File size: 2.16 KB
MIME-type: text/x-php
Charset: utf-8

<?php
/**
 * SportsPress Text Settings
 *
 * @author      ThemeBoy
 * @category    Admin
 * @package     SportsPress/Admin
 * @version     1.6
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

if ( ! class_exists( 'SP_Settings_Text' ) ) :

	/**
	 * SP_Settings_Text
	 */
	class SP_Settings_Text extends SP_Settings_Page {

		/**
		 * Constructor
		 */
		public function __construct() {
			$this->id    = 'text';
			$this->label = esc_attr__( 'Text', 'sportspress' );

			add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
			add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
			add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
		}

		/**
		 * Get settings array
		 *
		 * @return array
		 */
		public function get_settings() {

			$settings = array(
				array(
					'title' => esc_attr__( 'Text', 'sportspress' ),
					'type'  => 'title',
					'desc'  => esc_attr__( 'The following options affect how words are displayed on the frontend.', 'sportspress' ),
					'id'    => 'text_options',
				),
			);

			$strings = sp_get_text_options();
			$options = get_option( 'sportspress_text' );

			$options = array();
			foreach ( $strings as $string ) :
				$options[] = array(
					'title'       => $string,
					'id'          => 'sportspress_text[' . $string . ']',
					'default'     => '',
					'placeholder' => $string,
					'value'       => sp_array_value( $options, $string, null ),
					'type'        => 'text',
				);
			endforeach;

			$settings = array_merge(
				$settings,
				apply_filters( 'sportspress_text_options', $options ),
				array(
					array(
						'type' => 'sectionend',
						'id'   => 'text_options',
					),
				)
			);

			return apply_filters( 'sportspress_text_settings', $settings ); // End event settings
		}

		/**
		 * Save settings
		 */
		public function save() {
			if ( isset( $_POST['sportspress_text'] ) ) {
				update_option( 'sportspress_text', array_map( 'sanitize_text_field', array_map( 'wp_unslash', $_POST['sportspress_text'] ) ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
			}
		}
	}

endif;

return new SP_Settings_Text();