/inc/theme-options.php

  1. <?php  
  2. if ( ! defined( 'ABSPATH' ) ) exit; 
  3. /** 
  4. * Theme Options 
  5. * 
  6. * @package advantage 
  7. * @since advantage 1.0 
  8. */ 
  9. add_action( 'admin_init', 'advantage_theme_options_init' ); 
  10. add_action( 'admin_menu', 'advantage_theme_options_admin_menu' ); 
  11. function advantage_admin_enqueue_scripts( $hook_suffix ) { 
  12. global $advantage_options; 
  13. $advantage_options = advantage_get_options(); 
  14.  
  15. $template_uri = get_template_directory_uri();  
  16. wp_enqueue_style( 'wp-color-picker' ); 
  17. wp_enqueue_style( 'advantage-theme-options', $template_uri . '/css/theme-options.css', false, '1.0' ); 
  18. wp_enqueue_script( 'advantage-theme-options', $template_uri . '/js/theme-options.js', array('jquery', 'wp-color-picker'), '1.0' ); 
  19.  
  20. global $advantage_fonts; 
  21. $advantage_fonts = advantage_fonts_array(); 
  22. foreach ( $advantage_fonts as $font ) { 
  23. if ( ! empty( $font['url'] ) ) 
  24. wp_enqueue_style( str_replace(' ', '', $font['label'] ), $font['url'], false, '1.0' ); 
  25. add_action( 'admin_print_styles-appearance_page_theme_options', 'advantage_admin_enqueue_scripts' ); 
  26.  
  27. function advantage_theme_options_init() { 
  28. register_setting( 'advantage_options', 'advantage_theme_options', 'advantage_theme_options_validate' ); 
  29.  
  30. function advantage_theme_options_admin_menu() { 
  31. add_theme_page( __('Theme Options', 'advantage' ), __('Theme Options', 'advantage' ), 'edit_theme_options', 'theme_options', 'advantage_theme_options_display_page' ); 
  32.  
  33. function advantage_theme_options_array() {  
  34. global $advantage_fonts; 
  35.  
  36. $theme_options = array( 
  37. 'currenttab' => array( 
  38. 'name' => 'currenttab',  
  39. 'type' => 'hidden',  
  40. ),  
  41. // Layout 
  42. 'gridwidth' => array( 
  43. 'name' => 'gridwidth',  
  44. 'label' => __( 'Grid Width', 'advantage' ),  
  45. 'type' => 'number',  
  46. 'desc' => __( 'Pixels', 'advantage' ),  
  47. ),  
  48. 'content' => array( 
  49. 'name' => 'content',  
  50. 'label' => __( 'Content', 'advantage' ),  
  51. 'type' => 'number',  
  52. 'fieldonly' => '1',  
  53. ),  
  54. 'sidebar1' => array( 
  55. 'name' => 'sidebar1',  
  56. 'label' => __( 'Sidebar 1', 'advantage' ),  
  57. 'type' => 'number',  
  58. 'fieldonly' => '1',  
  59. ),  
  60. 'sidebar2' => array( 
  61. 'name' => 'sidebar2',  
  62. 'label' => __( 'Sidebar 2', 'advantage' ),  
  63. 'type' => 'number',  
  64. 'desc' => __( 'Columns', 'advantage' ),  
  65. 'fieldonly' => '1',  
  66. ),  
  67. 'sidebarpos' => array( 
  68. 'name' => 'sidebarpos',  
  69. 'label' => __( 'Sidebar Position', 'advantage' ),  
  70. 'type' => 'radio',  
  71. 'values' => array( 
  72. array( 'key' => 1, 'label' => __( 'Right ', 'advantage' ) ),  
  73. array( 'key' => 2, 'label' => __( 'Left ', 'advantage' ) ),  
  74. array( 'key' => 3, 'label' => __( 'Left & Right ', 'advantage' ) ),  
  75. ),  
  76. 'helptext' => __( 'Note: For Left & Right layout, Blog Widget Area (Full) will not be used. The total columns must be 12.', 'advantage' ),  
  77. ),  
  78. 'sidebarresp' => array( 
  79. 'name' => 'sidebarresp',  
  80. 'label' => __( 'Responsive Sidebar', 'advantage' ),  
  81. 'type' => 'checkbox',  
  82. 'desc' => __( 'Check to activate responsive sidebars when screen width below breakpoints', 'advantage' ),  
  83. ),  
  84. 'respbp' => array( 
  85. 'name' => 'respbp',  
  86. 'label' => __( 'Responsive Sidebar Breakpoint', 'advantage' ),  
  87. 'type' => 'number',  
  88. 'desc' => __( 'minimum 960 pixels', 'advantage' ),  
  89. ),  
  90. 'column_footer1' => array( 
  91. 'name' => 'column_footer1',  
  92. 'type' => 'number',  
  93. 'fieldonly' => '1',  
  94. ),  
  95. 'column_footer2' => array( 
  96. 'name' => 'column_footer2',  
  97. 'type' => 'number',  
  98. 'fieldonly' => '1',  
  99. ),  
  100. 'column_footer3' => array( 
  101. 'name' => 'column_footer3',  
  102. 'type' => 'number',  
  103. 'fieldonly' => '1',  
  104. ),  
  105. 'column_footer4' => array( 
  106. 'name' => 'column_footer4',  
  107. 'type' => 'number',  
  108. 'desc' => __( 'Columns', 'advantage' ),  
  109. 'fieldonly' => '1',  
  110. ),  
  111. 'column_home1' => array( 
  112. 'name' => 'column_home1',  
  113. 'type' => 'number',  
  114. 'fieldonly' => '1',  
  115. ),  
  116. 'column_home2' => array( 
  117. 'name' => 'column_home2',  
  118. 'type' => 'number',  
  119. 'fieldonly' => '1',  
  120. ),  
  121. 'column_home3' => array( 
  122. 'name' => 'column_home3',  
  123. 'type' => 'number',  
  124. 'fieldonly' => '1',  
  125. ),  
  126. 'column_home4' => array( 
  127. 'name' => 'column_home4',  
  128. 'type' => 'number',  
  129. 'fieldonly' => '1',  
  130. ),  
  131. 'column_home5' => array( 
  132. 'name' => 'column_home5',  
  133. 'type' => 'number',  
  134. 'desc' => __( 'Columns', 'advantage' ),  
  135. 'fieldonly' => '1',  
  136. ),  
  137. //Home Page 
  138. 'homepage' => array( 
  139. 'name' => 'homepage',  
  140. 'label' => __( 'Home Page Style', 'advantage' ),  
  141. 'type' => 'radio',  
  142. 'values' => array( 
  143. array( 'key' => 1,  
  144. 'label' => __( 'Featured Home', 'advantage' ) ),  
  145. array( 'key' => 2,  
  146. 'label' => __( 'Blog', 'advantage' ) ),  
  147. ),  
  148. ),  
  149. 'fp_option' => array( 
  150. 'name' => 'fp_option',  
  151. 'label' => __( 'Posts for Carousel', 'advantage' ),  
  152. 'type' => 'radio',  
  153. 'values' => array( 
  154. array( 'key' => 1,  
  155. 'label' => __( 'Featured Category', 'advantage' ) ),  
  156. array( 'key' => 2,  
  157. 'label' => __( 'Featured Posts', 'advantage' ) ),  
  158. ),  
  159. ),  
  160. 'fp_effect' => array( 
  161. 'name' => 'fp_effect',  
  162. 'label' => __( 'Animation', 'advantage' ),  
  163. 'type' => 'radio',  
  164. 'values' => array( 
  165. array( 'key' => 'slide',  
  166. 'label' => __( 'Slide', 'advantage' ) ),  
  167. array( 'key' => 'fade',  
  168. 'label' => __( 'Fade', 'advantage' ) ),  
  169. ),  
  170. ),  
  171. 'fp_category' => array( 
  172. 'name' => 'fp_category',  
  173. 'label' => __( 'Featured Category', 'advantage' ),  
  174. 'type' => 'category',  
  175. ),  
  176. 'headline' => array( 
  177. 'name' => 'headline',  
  178. 'label' => __( 'H1 Headline', 'advantage' ),  
  179. 'type' => 'text',  
  180. ),  
  181. 'tagline' => array( 
  182. 'name' => 'tagline',  
  183. 'label' => __( 'Tag lines', 'advantage' ),  
  184. 'type' => 'textarea',  
  185. 'row' => 3,  
  186. ),  
  187. // Skins 
  188. 'colorscheme' => array( 
  189. 'name' => 'colorscheme',  
  190. 'label' => __( 'Color Scheme', 'advantage' ),  
  191. 'type' => 'select',  
  192. 'values' => advantage_scheme_options(),  
  193. ),  
  194. 'schemecss' => array( 
  195. 'name' => 'schemecss',  
  196. 'type' => 'hidden',  
  197. ),  
  198. 'headerbg' => array( 
  199. 'name' => 'headerbg',  
  200. 'label' => __( 'Header Background', 'advantage' ),  
  201. 'type' => 'color',  
  202. ),  
  203. 'titlebarbg' => array( 
  204. 'name' => 'titlebarbg',  
  205. 'label' => __( 'Title Bar Background', 'advantage' ),  
  206. 'type' => 'color',  
  207. ),  
  208. 'contentbg' => array( 
  209. 'name' => 'contentbg',  
  210. 'label' => __( 'Content Background', 'advantage' ),  
  211. 'type' => 'color',  
  212. ),  
  213. 'footerbg' => array( 
  214. 'name' => 'footerbg',  
  215. 'label' => __( 'Footer Background', 'advantage' ),  
  216. 'type' => 'color',  
  217. ),  
  218. //Fonts 
  219. 'bodyfont' => array( 
  220. 'name' => 'bodyfont',  
  221. 'label' => __( 'Body / Paragraph', 'advantage' ),  
  222. 'type' => 'font',  
  223. 'values' => $advantage_fonts,  
  224. ),  
  225. 'sitetitlefont' => array( 
  226. 'name' => 'sitetitlefont',  
  227. 'label' => __( 'Site Title', 'advantage' ),  
  228. 'type' => 'font',  
  229. 'values' => $advantage_fonts,  
  230. ),  
  231. 'sitedescfont' => array( 
  232. 'name' => 'sitedescfont',  
  233. 'label' => __( 'Site Description', 'advantage' ),  
  234. 'type' => 'font',  
  235. 'values' => $advantage_fonts,  
  236. ),  
  237. 'entrytitlefont' => array( 
  238. 'name' => 'entrytitlefont',  
  239. 'label' => __( 'Post/Page Title', 'advantage' ),  
  240. 'type' => 'font',  
  241. 'values' => $advantage_fonts,  
  242. ),  
  243. 'headingfont' => array( 
  244. 'name' => 'headingfont',  
  245. 'label' => __( 'Heading (H1 - H6)', 'advantage' ),  
  246. 'type' => 'font',  
  247. 'values' => $advantage_fonts,  
  248. ),  
  249. 'sidebarfont' => array( 
  250. 'name' => 'sidebarfont',  
  251. 'label' => __( 'Sidebar', 'advantage' ),  
  252. 'type' => 'font',  
  253. 'values' => $advantage_fonts,  
  254. ),  
  255. 'widgettitlefont' => array( 
  256. 'name' => 'widgettitlefont',  
  257. 'label' => __( 'Widget Title', 'advantage' ),  
  258. 'type' => 'font',  
  259. 'values' => $advantage_fonts,  
  260. ),  
  261. 'footerfont' => array( 
  262. 'name' => 'footerfont',  
  263. 'label' => __( 'Footer', 'advantage' ),  
  264. 'type' => 'font',  
  265. 'values' => $advantage_fonts,  
  266. ),  
  267. 'mainmenufont' => array( 
  268. 'name' => 'mainmenufont',  
  269. 'label' => __( 'Main Menu', 'advantage' ),  
  270. 'type' => 'font',  
  271. 'values' => $advantage_fonts,  
  272. ),  
  273.  
  274. 'otherfont1' => array( 
  275. 'name' => 'otherfont1',  
  276. 'label' => __( 'Google Font 1', 'advantage' ),  
  277. 'type' => 'text',  
  278. ),  
  279. 'otherfont2' => array( 
  280. 'name' => 'otherfont2',  
  281. 'label' => __( 'Google Font 2', 'advantage' ),  
  282. 'type' => 'text',  
  283. ),  
  284. 'otherfont3' => array( 
  285. 'name' => 'otherfont3',  
  286. 'label' => __( 'Google Font 3', 'advantage' ),  
  287. 'type' => 'text',  
  288. ),  
  289. 'otherfont4' => array( 
  290. 'name' => 'otherfont4',  
  291. 'label' => __( 'Google Font 4', 'advantage' ),  
  292. 'type' => 'text',  
  293. 'helptext' => 'Enter Font Name only, e.g. Open Sans',  
  294. ),  
  295. // Custom CSS 
  296. 'advantage_inline_css' => array( 
  297. 'name' => 'advantage_inline_css',  
  298. 'label' => __( 'Custom CSS Style', 'advantage' ),  
  299. 'type' => 'textarea',  
  300. 'row' => 40,  
  301. ),  
  302. 'advantage_scheme_css' => array( 
  303. 'name' => 'advantage_scheme_css',  
  304. 'type' => 'hidden',  
  305. ),  
  306. ); 
  307. return apply_filters( 'advantage_theme_options_array', $theme_options ); 
  308.  
  309. function advantage_theme_options_display_page() { 
  310. if ( ! isset( $_REQUEST['settings-updated'] ) ) 
  311. $_REQUEST['settings-updated'] = false; 
  312. ?> 
  313. <div class="wrap"> 
  314. <?php screen_icon(); 
  315. echo "<h2>" . __('Advantage Theme Options', 'advantage') . "</h2>"; 
  316. if ( false !== $_REQUEST['settings-updated'] ) { ?> 
  317. <div class="updated fade"><p><strong><?php _e('Options Saved', 'advantage'); ?></strong></p></div> 
  318. <?php } ?> 
  319. <p><a class="btn btn-primary" href="<?php _e('http://xinthemes.com/docs/', 'advantage'); ?>" target="_blank"><strong><?php _e('Documentation', 'advantage'); ?></strong></a>   
  320. <a class="btn btn-warning" href="<?php _e('http://xinthemes.com/advantage-change-log/', 'advantage'); ?>" target="_blank"><strong><?php _e('Change Log', 'advantage'); ?></strong></a>   
  321. <a class="btn btn-success" href="<?php _e('http://xinthemes.com/support/', 'advantage'); ?>" target="_blank"><strong><?php _e('Support Forum', 'advantage'); ?></strong></a>   
  322. <a class="btn btn-info" href="<?php _e('http://xinthemes.com/donate/', 'advantage'); ?>" target="_blank"><strong><?php _e('Donate', 'advantage'); ?></strong></a></p> 
  323. <form method="post" action="options.php"> 
  324. <?php  
  325. global $advantage_theme_options, $advantage_options; 
  326. $advantage_theme_options = advantage_theme_options_array(); 
  327. $advantage_options = advantage_get_options(); 
  328. settings_fields( 'advantage_options' ); 
  329. ?> 
  330. <div id="advantage-wrapper" class="container_12"> 
  331. <input id="save-button" type="submit" class="button-primary" value="<?php _e('Save Options', 'advantage'); ?>" /> 
  332. <div id="advantage-tabs"> 
  333. <a><?php _e('Layout', 'advantage'); ?></a> 
  334. <a><?php _e('Scheme', 'advantage'); ?></a> 
  335. <a><?php _e('Fonts', 'advantage'); ?></a> 
  336. <a><?php _e('Custom CSS', 'advantage'); ?></a> 
  337. <?php //Allow child them to add options. 
  338. do_action( 'advantage_options_tab_link' ); ?> 
  339. </div> 
  340. <?php 
  341. /****************************************************************** 
  342. * Theme Options related to site layout 
  343. ******************************************************************/ 
  344. ?> 
  345. <div class="advantage-pane clearfix"><div class="grid_12"><!-- Layout --> 
  346. <h3><?php _e('Site Layout (12 Columns)', 'advantage'); ?></h3>  
  347. <?php xinwp_option_display( 'gridwidth' ); ?> 
  348. <div class="grid_3 alpha"> 
  349. <p><b><?php _e('Content and Sidebar Width', 'advantage'); ?></b></p> 
  350. </div> 
  351. <div class="grid_9"> 
  352. <?php 
  353. xinwp_option_display( 'content' ); 
  354. xinwp_option_display( 'sidebar1' ); 
  355. xinwp_option_display( 'sidebar2' ); 
  356. ?> 
  357. </div><div class="clear"></div> 
  358. <?php 
  359. xinwp_option_display( 'sidebarpos' ); 
  360. xinwp_option_display( 'sidebarresp' ); 
  361. xinwp_option_display( 'respbp' ); 
  362. ?> 
  363. <div class="grid_3 alpha"> 
  364. <p><b><?php _e('Home Widget Area Width', 'advantage'); ?></b></p> 
  365. </div> 
  366. <div class="grid_9"> 
  367. <?php 
  368. xinwp_option_display( 'column_home1' ); 
  369. xinwp_option_display( 'column_home2' ); 
  370. xinwp_option_display( 'column_home3' ); 
  371. xinwp_option_display( 'column_home4' ); 
  372. xinwp_option_display( 'column_home5' ); 
  373. ?> 
  374. </div><div class="clear"></div> 
  375. <div class="grid_3 alpha"> 
  376. <p><b><?php _e('Footer Widget Area Width', 'advantage'); ?></b></p> 
  377. </div> 
  378. <div class="grid_9"> 
  379. <?php 
  380. xinwp_option_display( 'column_footer1' ); 
  381. xinwp_option_display( 'column_footer2' ); 
  382. xinwp_option_display( 'column_footer3' ); 
  383. xinwp_option_display( 'column_footer4' ); 
  384. ?> 
  385. </div><div class="clear"></div> 
  386. <h3><?php _e('Home Page', 'advantage'); ?></h3> 
  387. <?php xinwp_option_display( 'homepage' ); 
  388. xinwp_option_display( 'fp_option' ); 
  389. xinwp_option_display( 'fp_category' ); 
  390. xinwp_option_display( 'fp_effect' ); 
  391. xinwp_option_display( 'headline' ); 
  392. xinwp_option_display( 'tagline' );  
  393. do_action( 'advantage_options_tab_layout' ); ?>  
  394. </div></div> 
  395. <?php 
  396. /****************************************************************** 
  397. * Theme Options: Scheme 
  398. ******************************************************************/ 
  399. ?> 
  400. <div class="advantage-pane clearfix"><div class="grid_12"> 
  401. <?php xinwp_option_display( 'colorscheme' ); ?> 
  402. <p><?php _e('Change Background Image or Color : ', 'advantage'); printf( __('<a href="%s">Click here</a>.', 'advantage'), admin_url('themes.php?page=custom-background')); ?></p> 
  403. <?php xinwp_option_display( 'headerbg' ); 
  404. xinwp_option_display( 'titlebarbg' ); 
  405. xinwp_option_display( 'contentbg' ); 
  406. xinwp_option_display( 'footerbg' ); 
  407. do_action( 'advantage_options_tab_scheme' ); 
  408. ?> 
  409. </div></div>  
  410. <?php 
  411. /************************************** 
  412. * Theme Options - Fonts * 
  413. **************************************/ 
  414. ?> 
  415. <div class="advantage-pane clearfix"><div class="grid_12"> 
  416. <p><?php _e( 'You do not need to select font for each element. For example. Body, paragraph and heading define the general fonts used. <span style="color:blue;font-weight:bold;">Please note that blue indicates webfonts (e.g Google Fonts) which may require additional load time.</span>', 'advantage' ); ?></p> 
  417. <?php  
  418. xinwp_option_display( 'bodyfont' ); 
  419. xinwp_option_display( 'headingfont' ); 
  420. ?> 
  421. <hr> 
  422. <?php 
  423. xinwp_option_display( 'sitetitlefont' ); 
  424. xinwp_option_display( 'sitedescfont' ); 
  425. ?> 
  426. <hr> 
  427. <?php 
  428. xinwp_option_display( 'entrytitlefont' ); 
  429. xinwp_option_display( 'widgettitlefont' ); 
  430. xinwp_option_display( 'sidebarfont' ); 
  431. xinwp_option_display( 'mainmenufont' ); 
  432. xinwp_option_display( 'footerfont' ); 
  433. ?> 
  434. <h3><?php _e( 'Additional Google Fonts', 'advantage' ); ?></h3> 
  435. <?php 
  436. xinwp_option_display( 'otherfont1' ); 
  437. xinwp_option_display( 'otherfont2' ); 
  438. xinwp_option_display( 'otherfont3' ); 
  439. xinwp_option_display( 'otherfont4' ); 
  440. do_action( 'advantage_options_tab_fonts' ); 
  441. ?> 
  442. </div></div> 
  443. <?php 
  444. /****************************************************************** 
  445. * Custom CSS 
  446. ******************************************************************/ 
  447. ?> 
  448. <div class="advantage-pane clearfix"><div class="grid_12"> 
  449. <?php 
  450. xinwp_option_display( 'advantage_inline_css' );  
  451. ?> 
  452. </div></div> 
  453. <?php 
  454. /****************************************************************** 
  455. * Child Theme Options 
  456. ******************************************************************/ 
  457. do_action( 'advantage_options_tab_page' ); 
  458.  
  459. xinwp_option_display( 'currenttab' ); 
  460. xinwp_option_display( 'schemecss' ); 
  461. xinwp_option_display( 'advantage_scheme_css' ); 
  462. ?> 
  463. <p><input id="save-button-bottom" type="submit" class="button-primary" value="<?php _e( 'Save Options', 'advantage' ); ?>" /></p> 
  464. </div><!-- advantage-wrapper --> 
  465. </form> 
  466. </div><!-- wrap --> 
  467. <?php 
  468.  
  469. function advantage_theme_options_validate( $input ) { 
  470. $theme_options = advantage_theme_options_array(); 
  471. foreach ( $theme_options as $theme_option ) { 
  472. switch ( $theme_option['type'] ) { 
  473. case 'checkbox': 
  474. if ( ! isset( $input[ $theme_option['name'] ] ) ) 
  475. $input[$theme_option['name']] = null; 
  476. $input[ $theme_option['name'] ] = ( $input[ $theme_option['name'] ] == 1 ? 1 : 0 ); 
  477. break; 
  478. case 'text': 
  479. case 'textarea': 
  480. $input[ $theme_option['name'] ] = wp_kses_stripslashes( $input[ $theme_option['name'] ] ); 
  481. break; 
  482. case 'number':  
  483. $input[ $theme_option['name'] ] = intval( $input[ $theme_option['name'] ] );  
  484. break;  
  485. case 'url':  
  486. $input[ $theme_option['name'] ] = esc_url_raw( $input[$theme_option['name'] ] );  
  487. break; 
  488. case 'color': 
  489. $input[ $theme_option['name'] ] = sanitize_text_field( $input[ $theme_option['name'] ] );  
  490. break; 
  491. if ( $input['respbp'] < 960 ) 
  492. $input['respbp'] = 960; 
  493. $input['advantage_scheme_css'] = advantage_scheme_css( $input ); 
  494. //Update Scheme Options 
  495. $options = advantage_get_options(); 
  496. if ( $input['colorscheme'] != $options['colorscheme'] ) { 
  497. $scheme = $theme_options['colorscheme']['values'][ $input['colorscheme'] ]; 
  498. $input['schemecss'] = $scheme['css'];  
  499. foreach ( $scheme['options'] as $scheme_options ) 
  500. $input[ $scheme_options['name'] ] = $scheme_options['value']; 
  501. return $input; 
  502.  
  503. function advantage_scheme_css($input) { 
  504. $advantage_fonts = advantage_fonts_array(); 
  505. $css = ''; 
  506. if ( 1080 != $input['gridwidth'] ) { 
  507. $css .= '.row, .contain-to-grid .top-bar {max-width: ' . $input['gridwidth'] . 'px; }' . "\n";  
  508. if ( 1 == $input['sidebarresp'] && 3 != $input['sidebarpos'] ) { 
  509. if ( ( $input['content'] + $input['sidebar1'] + $input['sidebar2']) <= 12 ) { 
  510. $pct = 8.547008547 * ( $input['sidebar1'] + $input['sidebar2'] ) - 2.764102564; 
  511. $css .= '@media only screen and (min-width: 768px) '; 
  512. $css .= 'and (max-width: ' . $input['respbp'] . 'px) {' . "\n"; 
  513. $css .= '#sidebar_one, #sidebar_two { width: ' . $pct; 
  514. $css .= '%; float: left; }}' . "\n"; 
  515. if ( 1 == $input['sidebarresp'] ) { 
  516. $pct = 48.71794872; 
  517. $css .= '@media only screen and (min-width: 481px) '; 
  518. $css .= 'and (max-width: 767px) {' . "\n"; 
  519. $css .= '#sidebar_one, #sidebar_two { width: ' . $pct; 
  520. $css .= '%; float: left; } #sidebar_two { margin-left: 2.564102564%; } }' . "\n"; 
  521. if ( $input['bodyfont'] > 0 ) 
  522. $css .= 'body {font-family:' . $advantage_fonts[ $input['bodyfont'] ]['family'] . ';}' . "\n"; 
  523. if ( $input['headingfont'] > 0 ) 
  524. $css .= 'h1, h2, h3, h4, h5, h6 {font-family:' . $advantage_fonts[$input['headingfont']]['family'] . ';}' . "\n"; 
  525. if ( $input['entrytitlefont'] > 0 ) 
  526. $css .= '.entry-title {font-family:' . $advantage_fonts[$input['entrytitlefont']]['family'] . ';}' . "\n"; 
  527. if ( $input['sitetitlefont'] > 0 ) 
  528. $css .= '#site-title {font-family:' . $advantage_fonts[$input['sitetitlefont']]['family'] . ';}' . "\n"; 
  529. if ( $input['sitedescfont'] > 0 ) 
  530. $css .= '#site-description {font-family:' . $advantage_fonts[$input['sitedescfont']]['family'] . ';}' . "\n"; 
  531. if ( $input['widgettitlefont'] > 0 ) 
  532. $css .= '.widget-title {font-family:' . $advantage_fonts[$input['widgettitlefont']]['family'] . ';}' . "\n"; 
  533. if ( $input['sidebarfont'] > 0 ) 
  534. $css .= '.blog-widgets {font-family:' . $advantage_fonts[$input['sidebarfont']]['family'] . ';}' . "\n"; 
  535. if ( $input['footerfont'] > 0 ) 
  536. $css .= '#footer {font-family:' . $advantage_fonts[$input['footerfont']]['family'] . ';}' . "\n"; 
  537. if ( $input['mainmenufont'] > 0 ) 
  538. $css .= '#topbar {font-family:' . $advantage_fonts[$input['mainmenufont']]['family'] . ';}' . "\n"; 
  539. //Background 
  540. if ( ! empty( $input['headerbg'] ) ) 
  541. $css .= '.custom-background .site-header, .site-header {background:' . $input['headerbg'] . ';}' . "\n"; 
  542. if ( ! empty( $input['titlebarbg'] ) ) 
  543. $css .= '.custom-background .titlebar, .titlebar {background:' . $input['titlebarbg'] . ';}' . "\n"; 
  544. if ( ! empty( $input['contentbg'] ) ) 
  545. $css .= '.custom-background .content-area, .content-area {background:' . $input['contentbg'] . ';}' . "\n"; 
  546. if ( ! empty( $input['footerbg'] ) ) 
  547. $css .= '.custom-background #footer, #footer {background:' . $input['footerbg'] . ';}' . "\n"; 
  548. return apply_filters( 'advantage_scheme_css', $css ); 
  549.  
  550. function xinwp_option_display( $option_name ) { 
  551. global $advantage_options, $advantage_theme_options, $advantage_fonts; 
  552. $theme_option = $advantage_theme_options[ $option_name ]; 
  553. $options = $advantage_options; 
  554. if ( $theme_option['type'] != 'hidden' && empty( $theme_option['fieldonly'] ) ) { 
  555. if ( isset( $theme_option['label'] ) ) { 
  556. echo '<div class="grid_3 alpha">';  
  557. echo '<p><b>' . $theme_option['label'] . '</b></p></div>';  
  558. echo '<div class="grid_9"><p>';  
  559. switch ( $theme_option['type'] ) { 
  560. case 'radio': 
  561. $values = $theme_option['values']; 
  562. foreach ( $values as $value ) { 
  563. printf( '<input id="advantage_theme_options[%1$s]_%2$s" name="advantage_theme_options[%1$s]" type="radio" value="%2$s" %3$s />',  
  564. $theme_option['name'],  
  565. $value['key'],  
  566. checked( $value['key'], $options[$theme_option['name']], false ) ); 
  567. printf( '<label class="description" for="advantage_theme_options[%1$s]_%2$s">%3$s</label>',  
  568. $theme_option['name'],  
  569. $value['key'],  
  570. esc_attr( $value['label'] ) ); 
  571. break; 
  572. case 'checkbox': 
  573. printf( '<input id="advantage_theme_options[%1$s]" name="advantage_theme_options[%1$s]" type="checkbox" value="1" %2$s />',  
  574. $theme_option['name'],  
  575. checked( '1', $options[$theme_option['name']], false ) ); 
  576. printf( '<label class="description" for="advantage_theme_options[%1$s]">%2$s</label>',  
  577. $theme_option['name'],  
  578. esc_attr( $theme_option['desc'] ) ); 
  579. break;  
  580. case 'url': 
  581. case 'text': 
  582. printf( '<input name="advantage_theme_options[%s]" type="text" value="%s" size="80" />',  
  583. $theme_option['name'],  
  584. esc_attr( $options[$theme_option['name']] ) ); 
  585. break; 
  586. case 'color': 
  587. printf( '<input name="advantage_theme_options[%1$s]" type="text" value="%2$s" class="advantage-color-field" />',  
  588. $theme_option['name'],  
  589. esc_attr( $options[$theme_option['name']] ) ); 
  590. break; 
  591. case 'textarea': 
  592. printf( '<textarea name="advantage_theme_options[%s]" cols="120" rows="%s">%s</textarea>',  
  593. $theme_option['name'],  
  594. $theme_option['row'],  
  595. esc_textarea( $options[ $theme_option['name'] ] ) ); 
  596. break; 
  597. case 'number': 
  598. if ( ! empty( $theme_option['fieldonly'] ) && ! empty( $theme_option['label'] ) ) 
  599. printf( '<label class="description">%s</label>', esc_attr( $theme_option['label'] ) ); 
  600. printf( '<input name="advantage_theme_options[%s]" type="text" value="%s" size="4" />',  
  601. $theme_option['name'],  
  602. esc_attr( $options[ $theme_option['name'] ] ) ); 
  603. if ( ! empty( $theme_option['desc'] ) ) 
  604. printf( '<label class="description">%s</label>', esc_attr( $theme_option['desc'] ) ); 
  605. echo '    '; 
  606. break; 
  607. case 'select': 
  608. printf( '<select name="advantage_theme_options[%s]" >',  
  609. $theme_option['name'] ); 
  610. foreach ( $theme_option['values'] as $value ) { 
  611. printf ('<option value="%1$s" %2$s>%3$s</option>',  
  612. $value['key'],  
  613. selected( $options[$theme_option['name']], $value['key'], false ),  
  614. $value['label'] ); 
  615. echo '</select>'; 
  616. break; 
  617. case 'font': 
  618. printf( '<select style="font-family:%2$s;font-size:14px;" name="advantage_theme_options[%1$s]" >',  
  619. $theme_option['name'],  
  620. $advantage_fonts[ $options[ $theme_option['name'] ] ]['family'] ); 
  621. $old_font_type = ''; 
  622. foreach ( $theme_option['values'] as $value ) { 
  623. if ( $value['type'] != $old_font_type ) { 
  624. if ( $old_font_type != '' ) 
  625. echo '</optgroup>'; 
  626. printf( '<optgroup label="%1$s">', $value['type'] );  
  627. printf( '<option style="font-family: %4$s;%5$s" value="%1$s" %2$s>%3$s</option>',  
  628. $value['key'],  
  629. selected( $options[ $theme_option['name'] ], $value['key'], false ),  
  630. $value['label'],  
  631. $value['family'],  
  632. ( empty( $value['url'] ) ? '' : 'color:blue;' ) ); 
  633. $old_font_type = $value['type'];  
  634. echo '</optgroup>'; 
  635. echo '</select>'; 
  636. printf( '  <span style="font-family:%2$s;font-size:16px;%3$s">%1$s</span>',  
  637. 'The quick brown fox jumps over the lazy dog.',  
  638. $advantage_fonts[$options[$theme_option['name']]]['family'],  
  639. ( empty($advantage_fonts[ $options[ $theme_option['name'] ] ]['url'] ) ? '' : 'color:blue;' ) ); 
  640. break; 
  641. case 'category': 
  642. printf( '<select name="advantage_theme_options[%s]" >',  
  643. $theme_option['name'] ); 
  644. $selected_category = $options[ $theme_option['name'] ]; 
  645. printf( '<option value="0" %1$s>%2$s</option>',  
  646. selected( $options[ $theme_option['name'] ], 0, false ),  
  647. __('All Categories', 'advantage') ); 
  648.  
  649. foreach ( advantage_categories() as $option ) { 
  650. printf( '<option value="%1$s" %2$s>%3$s</option>',  
  651. $option->term_id,  
  652. selected( $selected_category, $option->term_id, false ),  
  653. $option->name ); 
  654. echo '</select>'; 
  655. break; 
  656. case 'hidden': 
  657. printf( '<input id="%1$s" name="advantage_theme_options[%1$s]" type="hidden" value="%2$s" />',  
  658. $theme_option['name'],  
  659. esc_attr( $options[ $theme_option['name'] ] ) ); 
  660. break; 
  661. default: 
  662. echo __( 'Not Availavle Yet', 'advantage' );  
  663. if ( $theme_option['type'] != 'hidden' && empty( $theme_option['fieldonly'] ) ) { 
  664. echo '</p>'; 
  665. if ( ! empty( $theme_option['helptext'] ) ) 
  666. printf( '<p><label class="helptext">%s</label></p>', $theme_option['helptext']); 
  667. echo '</div><div class="clear"></div>';  
.