add_section( 'footer', array( 'title' => esc_html__( 'Footer', 'omega' ), 'priority' => 149, 'capability' => 'edit_theme_options' ) ); /* Add the 'footer_insert' setting. */ $wp_customize->add_setting( "custom_footer", array( 'default' => apply_filters( 'omega_footer_insert', '' ), 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'omega_customize_sanitize', 'sanitize_js_callback' => 'omega_customize_sanitize', 'transport' => 'postMessage', ) ); /* Add the textarea control for the 'footer_insert' setting. */ $wp_customize->add_control( new Omega_Footer_Textarea( $wp_customize, 'omega-footer', array( 'section' => 'footer', 'settings' => "custom_footer", ) ) ); /* If viewing the customize preview screen, add a script to show a live preview. */ if ( $wp_customize->is_preview() && !is_admin() ) add_action( 'wp_footer', 'omega_customize_preview_footer_script', 21 ); } } /** * Sanitizes the footer content on the customize screen. Users with the 'unfiltered_html' cap can post * anything. For other users, wp_filter_post_kses() is ran over the setting. * * @since 1.0.0 * @access public * @param mixed $setting The current setting passed to sanitize. * @param object $object The setting object passed via WP_Customize_Setting. * @return mixed $setting */ if ( !function_exists('omega_customize_sanitize') ) { function omega_customize_sanitize( $setting, $object ) { /* Make sure we kill evil scripts from users without the 'unfiltered_html' cap. */ if ( "omega_theme_settings[footer_insert]" == $object->id && !current_user_can( 'unfiltered_html' ) ) $setting = stripslashes( wp_filter_post_kses( addslashes( $setting ) ) ); /* Return the sanitized setting and apply filters. */ return apply_filters( "omega_customize_sanitize", $setting, $object ); } } /** * Runs the footer content posted via Ajax through the do_shortcode() function. This makes sure the * shortcodes are output correctly in the live preview. * * @since 1.0.0 * @access private */ if ( !function_exists('omega_customize_footer_content_ajax') ) { function omega_customize_footer_content_ajax() { /* Check the AJAX nonce to make sure this is a valid request. */ check_ajax_referer( 'omega_customize_footer_content_nonce' ); /* If footer content has been posted, run it through the do_shortcode() function. */ if ( isset( $_POST['footer_content'] ) ) echo do_shortcode( wp_kses_stripslashes( $_POST['footer_content'] ) ); /* Always die() when handling Ajax. */ die(); } } /** * Handles changing settings for the live preview of the theme. * * @since 1.0.0 * @access private */ if ( !function_exists('omega_customize_preview_footer_script') ) { function omega_customize_preview_footer_script() { /* Create a nonce for the Ajax. */ $nonce = wp_create_nonce( 'omega_customize_footer_content_nonce' ); ?>