$this->slug, 'name' => esc_html__( 'Adobe Fonts (formerly Typekit)', 'powerkit' ), 'function' => array( $this, 'build_setting_page' ), ); return $settings; } /** * Build admin page * * @since 1.0.0 */ public function build_setting_page() { $this->save_options_page(); $this->synchronization(); ?>

  1. %2$s', esc_url( 'https://fonts.adobe.com/' ), esc_html__( 'Adobe Fonts account', 'powerkit' ) ); ?>
  2. %1$s', esc_url( 'https://fonts.adobe.com/account/tokens' ) ); ?>
get( null, $token ); if ( $typekit_data && isset( $typekit_data['kits'] ) && $typekit_data['kits'] ) { ?>

get( $typekit_kit, $token ); // If exist families. if ( isset( $typekit_data['kit']['families'] ) && $typekit_data['kit']['families'] ) { // First stack for example. if ( isset( $typekit_data['kit']['families']['0']['css_stack'] ) ) { $first_stack = $typekit_data['kit']['families']['0']['css_stack']; } // First family variant for example. if ( isset( $typekit_data['kit']['families']['0']['variations']['0'] ) ) { $first_variant = $typekit_data['kit']['families']['0']['variations']['0']; $first_variant = powerkit_typekit_font_convert_format( $first_variant ); } // Example code. if ( isset( $first_stack ) && isset( $first_variant ) ) { $first_weight = isset( $first_variant['weight'] ) ? $first_variant['weight'] : 'normal'; $first_style = isset( $first_variant['style'] ) ? $first_variant['style'] : 'normal'; $code = sprintf( 'h1 { font-family: %s; font-weight: %s; font-style: %s; }', $first_stack, $first_weight, $first_style ); $code = str_replace( "\t\t", '', $code ); ?>

synchronization( true ); if ( isset( $_POST['powerkit_typekit_fonts_token'] ) ) { // Input var ok. update_option( 'powerkit_typekit_fonts_token', sanitize_text_field( wp_unslash( $_POST['powerkit_typekit_fonts_token'] ) ) ); // Input var ok. } if ( isset( $_POST['powerkit_typekit_fonts_kit'] ) ) { // Input var ok. update_option( 'powerkit_typekit_fonts_kit', sanitize_text_field( wp_unslash( $_POST['powerkit_typekit_fonts_kit'] ) ) ); // Input var ok. } printf( '

%s

', esc_html__( 'Settings saved.', 'powerkit' ) ); } } /** * Synchronization TypeKit * * @param boool $forcibly Forcibly Synchronization. */ protected function synchronization( $forcibly = false ) { if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'] ) ) { // Input var ok; sanitization ok. return; } if ( isset( $_POST['powerkit_typekit_reset_cache'] ) || $forcibly ) { // Input var ok. global $wpdb; $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'pk_typekit_%%'" ); // db call ok; no-cache ok. printf( '

%s

', esc_html__( 'Font kits synchronized.', 'powerkit' ) ); } } }