PATH:
home
/
centosnipponia
/
public_html
/
BAK_doohannl
/
wp-content
/
themes
/
sydney-pro-ii
/
inc
/
customizer
<?php /** * Customizer * Ajax callback functions * * @package Sydney */ /** * Adobe fonts control kits ajax callback */ function sydney_typography_adobe_kits_control() { check_ajax_referer( 'customize-typography-adobe-kits-control-nonce', 'nonce' ); $token = isset( $_POST['token'] ) ? wp_strip_all_tags( wp_unslash( $_POST['token'] ) ) : ''; $url = 'https://typekit.com/api/v1/json/kits/'; $response = wp_remote_request( $url . '?token=' . esc_attr( $token ), array() ); if ( wp_remote_retrieve_response_code( $response ) != '200' ) { update_option( 'sydney_adobe_fonts_kits', array() ); wp_send_json( array( 'status' => 'error', 'output' => '<p>' . esc_html__( 'Invalid API token.', 'sydney' ) . '</p>' ) ); } $fonts = array(); $response_body = json_decode( wp_remote_retrieve_body( $response ) ); foreach( $response_body->kits as $kit ) { $url = 'https://typekit.com/api/v1/json/kits/' . esc_attr( $kit->id ) . '?token=' . esc_attr( $token ); $response = wp_remote_request( $url, array() ); if ( wp_remote_retrieve_response_code( $response ) === 200 ) { $response_body = json_decode( wp_remote_retrieve_body( $response ) ); $fonts[ $response_body->kit->id ] = array( 'enable' => true, 'project_name' => $response_body->kit->name ); foreach( $response_body->kit->families as $family ) { $fonts[ $response_body->kit->id ][ 'families' ][] = array( 'name' => $family->name, 'css_name' => $family->css_names, 'css_stack' => $family->css_stack, 'subset' => $family->subset, 'variations' => $family->variations ); } update_option( 'sydney_adobe_fonts_kits', $fonts ); } } // Token is valid // But there's no fonts attached to the token if( count( $fonts ) === 0 ) { $output = sprintf( /* translators: 1: Adobe Fonts docs link */ __( 'Your API token is valid but you don\'t have fonts attached to this token. Click <a href="%s" target="_blank">here</a> to learn more about that.', 'sydney' ), 'https://docs.athemes.com/article/441-how-to-use-adobe-fonts' ); if( defined( 'BOTIGA_AWL_ACTIVE' ) ) { $output = __( 'Your API token is valid but you don\'t have fonts attached to this token.', 'sydney' ); } wp_send_json( array( 'status' => 'error', 'output' => '<p>' . wp_kses_post( $output ) . '</p>' ) ); } // Success. // There's fonts attached to the token wp_send_json( array( 'status' => 'success', 'output' => sydney_customize_control_adobe_font_kits_output( get_option( 'sydney_adobe_fonts_kits' ), false ) ) ); } add_action('wp_ajax_sydney_typography_adobe_kits_control', 'sydney_typography_adobe_kits_control'); /** * Adobe fonts control enable/disable kits ajax callback */ function sydney_typography_adobe_kits_control_enable_disable() { check_ajax_referer( 'customize-typography-adobe-kits-control-onoff-nonce', 'nonce' ); $kit_id = isset( $_POST['kit'] ) ? wp_strip_all_tags( wp_unslash( $_POST['kit'] ) ) : ''; $kits = get_option( 'sydney_adobe_fonts_kits', false ); if( $kits[ $kit_id ]['enable'] ) { $kits[ $kit_id ]['enable'] = 0; } else { $kits[ $kit_id ]['enable'] = 1; } update_option( 'sydney_adobe_fonts_kits', $kits ); wp_send_json( array( 'status' => 'success', 'kit_id' => $kit_id, 'kit_enabled' => $kits[ $kit_id ]['enable'] ) ); } add_action('wp_ajax_sydney_typography_adobe_kits_control_enable_disable', 'sydney_typography_adobe_kits_control_enable_disable');
[+]
..
[+]
controls
[+]
options
[+]
upsell
[-] ajax-callbacks.php
[edit]
[-] callbacks.php
[edit]
[-] customizer-hooks.php
[edit]
[-] customizer.php
[edit]
[-] sanitize.php
[edit]
[-] .htaccess.disabled
[edit]