# essential-widgets/2.2/includes/ctp-tabs-removal.php

Essential Widgets, version 2.2. 81 lines.

- Page: https://pluginprobe.com/plugins/essential-widgets/2.2/code/includes/ctp-tabs-removal.php
- Raw: https://pluginprobe.com/plugins/essential-widgets/2.2/raw/includes/ctp-tabs-removal.php
- Modified: 2023-11-15T17:02:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/essential-widgets/2.2/code/includes/ctp-tabs-removal.php#L10-L20`.

```php
<?php
/**
 * ctp_register_settings
 * CTP Register Settings
 */
if ( ! function_exists( 'ctp_register_settings' ) ) {
	function ctp_register_settings() {
		// register_setting( $option_group, $option_name, $sanitize_callback )
		register_setting(
			'ctp-group',
			'ctp_options',
			array()
		);
	}
}
add_action( 'admin_init', 'ctp_register_settings' );

if ( ! function_exists( 'ctp_get_options' ) ) {
	/**
	 * Returns the options array for ctp_get options
	 *
	 *  @since    1.3
	 */
	function ctp_get_options() {
		$defaults = ctp_default_options();
		$options  = get_option( 'ctp_options', $defaults );

		return wp_parse_args( $options, $defaults );
	}
}

if ( ! function_exists( 'ctp_default_options' ) ) {
	/**
	 * Return array of default options
	 *
	 * @since     1.3
	 * @return    array    default options.
	 */
	function ctp_default_options( $option = null ) {
		$default_options['theme_plugin_tabs'] = 1;
		if ( null == $option ) {
			return apply_filters( 'ctp_options', $default_options );
		} else {
			return $default_options[ $option ];
		}
	}
}

if ( ! function_exists( 'ctp_switch' ) ) {
	/**
	 * Return $string
	 *
	 * @since     1.3
	 * @return    $string    1 or 2.
	 */
	function ctp_switch() {
		if ( ! wp_verify_nonce( $_POST['security'], 'ew_switch_tabs_nonce' ) ) {
			wp_die( esc_html__( 'Unauthorized access!', 'essential-widgets' ) );
		} else {
			if ( ! current_user_can( 'manage_options' ) ) {
				wp_die( esc_html__( 'Permission denied!', 'essential-widgets' ) );
			}
			$value = ( 'true' == $_POST['value'] ) ? 1 : 0;

			$option_name = $_POST['option_name'];

			$option_value = ctp_get_options();

			$option_value[ $option_name ] = $value;

			if ( update_option( 'ctp_options', $option_value ) ) {
				echo $value;
			} else {
				esc_html_e( 'Connection Error. Please try again.', 'essential-widgets' );
			}
		}
		wp_die(); // this is required to terminate immediately and return a proper response
	}
}
add_action( 'wp_ajax_ctp_switch', 'ctp_switch' );

```
