Advertisement
Guest User

Fonts

a guest
Dec 19th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. <?php
  2.  
  3. $invxtassy_body_font_get = cs_get_option('body_font');
  4. $invxtassy_heading_font_get = cs_get_option('heading_font');
  5.  
  6. function invxtassy_body_gf_url() {
  7. $font_url = '';
  8. $invxtassy_body_font_get = cs_get_option('body_font');
  9. /*
  10. Translators: If there are characters in your language that are not supported
  11. by chosen font(s), translate this to 'off'. Do not translate into your own language.
  12. */
  13.  
  14. if ( 'off' !== _x( 'on', 'Google font: on or off', 'invxtassy' ) ) {
  15. $font_url = add_query_arg( 'family', urlencode( ''.$invxtassy_body_font_get['family'].':300,300i,400,400i,500,500i,600,600i,700,700i,900,900i&subset=latin,latin-ext' ), "//fonts.googleapis.com/css" );
  16. }
  17. return $font_url;
  18. }
  19.  
  20. if($invxtassy_heading_font_get['family'] == $invxtassy_body_font_get['family']) {} else {
  21. function invxtassy_heading_gf_url() {
  22. $font_url = '';
  23. $invxtassy_heading_font_get = cs_get_option('heading_font');
  24. /*
  25. Translators: If there are characters in your language that are not supported
  26. by chosen font(s), translate this to 'off'. Do not translate into your own language.
  27. */
  28.  
  29. if ( 'off' !== _x( 'on', 'Google font: on or off', 'invxtassy' ) ) {
  30. $font_url = add_query_arg( 'family', urlencode( ''.$invxtassy_heading_font_get['family'].':300,300i,400,400i,500,500i,600,600i,700,700i,900,900i&subset=latin,latin-ext' ), "//fonts.googleapis.com/css" );
  31. }
  32. return $font_url;
  33. }
  34. }
  35.  
  36. function invxtassy_options_gf() {
  37. wp_enqueue_style( 'invxtassy-custom-google-fonts', invxtassy_body_gf_url(), array(), '1.0.0' );
  38.  
  39. $invxtassy_body_font_get = cs_get_option('body_font');
  40. $invxtassy_heading_font_get = cs_get_option('heading_font');
  41. if($invxtassy_heading_font_get['family'] == $invxtassy_body_font_get['family']) {} else {
  42. wp_enqueue_style( 'invxtassy-google-heading-fonts', invxtassy_heading_gf_url(), array(), '1.0.0' );
  43. }
  44. }
  45. add_action( 'wp_enqueue_scripts', 'invxtassy_options_gf' );
  46.  
  47.  
  48. I used Codestar framework to select font family & weight.
  49.  
  50.  
  51. $body_font = cs_get_option('body_font');
  52. $heading_font = cs_get_option('heading_font');
  53.  
  54.  
  55. if (!empty($body_font)) {
  56. $custom_css .= "
  57. body{
  58. font-family: {$body_font['family']};
  59. font-weight: {$body_font['variant']};
  60. }
  61. ";
  62. }
  63.  
  64. if (!empty($heading_font)) {
  65. $custom_css .= "
  66. h1, h2, h3, h4, h5, h6{
  67. font-family: {$heading_font['family']};
  68. font-weight: {$heading_font['variant']};
  69. }
  70. ";
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement