PluginProbe
Catch Breadcrumb / 1.7
Catch Breadcrumb v1.7
trunk 1.0.0 1.0.1 1.0.2 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6 1.7 1.8 1.9 2.0 2.1 2.2 All 29 releases
catch-breadcrumb / includes / ctp-tabs-removal.php

ctp-tabs-removal.php in Catch Breadcrumb 1.7, at includes/ctp-tabs-removal.php

83 lines 2.1 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 * Header Enhacement Pro 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.9
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.9
37 * @return string 1 or 2.
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 } else {
44 return $default_options[ $option ];
45 }
46 }
47 }
48
49 if ( ! function_exists( 'ctp_switch' ) ) {
50 /**
51 * Return $string
52 *
53 * @since 1.2
54 * @return $string 1 or 2.
55 */
56 function ctp_switch() {
57 // Check nonce before doing and changes.
58 if ( ! check_ajax_referer( 'catch_breadcrumb_plugin_tabs_nonce', 'catch_breadcrumb_plugin_tabs_security', false ) ) {
59 wp_die( esc_html__( 'Invalid Nonce', 'catch-breadcrumb' ) );
60 } else {
61 if ( ! current_user_can( 'manage_options' ) ) {
62 wp_die( esc_html__( 'Permission denied!', 'catch-breadcrumb' ) );
63 }
64
65 $value = ( 'true' === $_POST['value'] ) ? 1 : 0;
66
67 $option_name = sanitize_text_field( $_POST['option_name'] );
68
69 $option_value = ctp_get_options();
70
71 $option_value[ $option_name ] = absint( $value );
72
73 if ( update_option( 'ctp_options', $option_value ) ) {
74 echo esc_html( $value );
75 } else {
76 esc_html_e( 'Connection Error. Please try again.', 'catch-breadcrumb' );
77 }
78 }
79 wp_die(); // this is required to terminate immediately and return a proper response
80 }
81 }
82 add_action( 'wp_ajax_ctp_switch', 'ctp_switch' );
83