The Text Preview for Add-Ons Ultimate plugin allows you to define which fonts the user can pick from. If you would like to define different fonts for different text preview fields, you can use the snippet below.
Note a couple of things:
- You’ll need to update the field IDs to match the IDs of your fields
- You should list the fonts in this format:
'arial' => 'Arial'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Filter the available fonts for each text preview field | |
| * List fonts in arrays using 'abel' => 'Abel' key / value pairs | |
| * Update the field IDs to match your own | |
| */ | |
| function demo_filter_all_fonts( $all_fonts, $available_fonts, $field ) { | |
| // Update the field IDs below to match your field IDs | |
| if( $field['field_id'] == 1209 ) { | |
| // Make an array of fonts for this field only | |
| $available_fonts = array( | |
| 'abel' => 'Abel', | |
| 'arial' => 'Arial' | |
| ); | |
| } else if( $field['field_id'] == 1307 ) { | |
| // Make an array of fonts for this field only | |
| $available_fonts = array( | |
| 'abel' => 'Abel', | |
| 'courier' => 'Courier' | |
| ); | |
| } | |
| $all_fonts = array_merge( array( 'default' => __( 'Default theme font', 'pr-advanced-previews-addons-ultimate' ) ), $available_fonts ); | |
| return $all_fonts; | |
| } | |
| add_filter( 'apaou_all_fonts', 'demo_filter_all_fonts', 10, 3 ); |
Here’s how to add the snippet.