PluginProbe
Essential Widgets / 1.5
Essential Widgets v1.5
3.2.1 3.3 3.2 trunk 1.0.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.3 1.4 1.4.1 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 1.9 2.0 2.1 2.2 All 31 releases
essential-widgets / includes / ctp-tabs-removal.php

ctp-tabs-removal.php in Essential Widgets 1.5, at includes/ctp-tabs-removal.php

75 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * ctp_register_settings
4 * CTP Register Settings
5 */
6 if( ! function_exists( 'ctp_register_settings' ) ) {
7 function ctp_register_settings() {
8 // register_setting( $option_group, $option_name, $sanitize_callback )
9 register_setting(
10 'ctp-group',
11 'ctp_options',
12 array()
13 );
14 }
15 }
16 add_action( 'admin_init', 'ctp_register_settings' );
17
18 if( ! function_exists( 'ctp_get_options' ) ) {
19 /**
20 * Returns the options array for ctp_get options
21 *
22 * @since 1.3
23 */
24 function ctp_get_options(){
25 $defaults = ctp_default_options();
26 $options = get_option( 'ctp_options', $defaults );
27
28 return wp_parse_args( $options, $defaults ) ;
29 }
30 }
31
32 if( ! function_exists( 'ctp_default_options' ) ) {
33 /**
34 * Return array of default options
35 *
36 * @since 1.3
37 * @return array default options.
38 */
39 function ctp_default_options( $option = null ) {
40 $default_options['theme_plugin_tabs'] = 1;
41 if ( null == $option ) {
42 return apply_filters( 'ctp_options', $default_options );
43 }
44 else {
45 return $default_options[ $option ];
46 }
47 }
48 }
49
50 if( ! function_exists( 'ctp_switch' ) ){
51 /**
52 * Return $string
53 *
54 * @since 1.3
55 * @return $string 1 or 2.
56 */
57 function ctp_switch() {
58 $value = ( 'true' == $_POST['value'] ) ? 1 : 0;
59
60 $option_name = $_POST['option_name'];
61
62 $option_value = ctp_get_options();
63
64 $option_value[$option_name] = $value;
65
66 if( update_option( 'ctp_options', $option_value ) ) {
67 echo $value;
68 } else {
69 esc_html_e( 'Connection Error. Please try again.', 'to-top' );
70 }
71
72 wp_die(); // this is required to terminate immediately and return a proper response
73 }
74 }
75 add_action( 'wp_ajax_ctp_switch', 'ctp_switch' );