Changeset 2086
- Timestamp:
- 11/17/2015 04:34:57 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-fonts/wc-fonts.php
r1815 r2086 16 16 add_action( 'wp_head', array( $this, 'wp_head_typekit' ), 102 ); // after safecss_style 17 17 add_action( 'wp_head', array( $this, 'wp_head_google_web_fonts' ) ); 18 add_action( 'wp_head', array( $this, 'wp_head_font_awesome' ) ); 18 19 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_icon_fonts' ) ); 19 20 } … … 36 37 printf( '<script type="text/javascript">try{Typekit.load();}catch(e){}</script>' ); 37 38 } 38 39 39 40 /** 40 41 * Provides the <head> output for Google Web Fonts … … 48 49 49 50 /** 51 * Provides the <head> output for Font Awesome 52 */ 53 function wp_head_font_awesome() { 54 if ( empty( $this->options['font-awesome-url'] ) ) { 55 return; 56 } 57 58 printf( "<style>@import url( '%s' );</style>", esc_url( $this->options['font-awesome-url'] ) ); 59 } 60 61 /** 50 62 * Runs during admin init, does Settings API 51 63 */ … … 56 68 add_settings_field( 'typekit-id', 'Typekit ID', array( $this, 'field_typekit_id' ), 'wc-fonts-options', 'general' ); 57 69 add_settings_field( 'google-web-fonts', 'Google Web Fonts', array( $this, 'field_google_web_fonts' ), 'wc-fonts-options', 'general' ); 70 add_settings_field( 'font-awesome-url', 'Font Awesome', array( $this, 'field_font_awesome_url' ), 'wc-fonts-options', 'general' ); 58 71 } 59 72 … … 108 121 109 122 /** 123 * Settings API field for the Google Web Fonts URLs 124 */ 125 function field_font_awesome_url() { 126 $value = isset( $this->options['font-awesome-url'] ) ? $this->options['font-awesome-url'] : ''; 127 ?> 128 129 <input type="text" name="wc-fonts-options[font-awesome-url]" value="<?php echo esc_url( $value ); ?>" class="large-text code" /> 130 <p class="description">Enter the BootstrapCDN URL for the version you want.</p> 131 132 <?php 133 } 134 135 /** 110 136 * Triggered by the Settings API upon settings save. 111 137 */ … … 113 139 $output = $this->options; 114 140 141 // Typekit 115 142 if ( isset( $input['typekit-id'] ) ) 116 143 $output['typekit-id'] = preg_replace( '/[^0-9a-zA-Z]+/', '', $input['typekit-id'] ); 117 144 145 // Google Web Fonts 118 146 if ( isset( $input['google-web-fonts'] ) ) { 119 147 $fonts = array(); … … 142 170 } 143 171 172 // Font Awesome 173 $output['font-awesome-url'] = ''; 174 175 if ( isset( $input['font-awesome-url'] ) ) { 176 $url = parse_url( $input['font-awesome-url'] ); 177 178 if ( isset( $url['host'] ) && isset( $url['path'] ) ) { 179 $valid_hostname = 'maxcdn.bootstrapcdn.com' === $url['host']; 180 $valid_extension = '.css' === substr( $url['path'], strlen( $url['path'] ) - 4, 4 ); 181 182 if ( $valid_hostname && $valid_extension ) { 183 $output['font-awesome-url'] = esc_url_raw( 'https://' . $url['host'] . $url['path'] ); 184 } 185 } 186 } 187 144 188 return $output; 145 189 }
Note: See TracChangeset
for help on using the changeset viewer.