An updated theme (based on Atticus Finch) for ClassicPress
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

975 lines
32 KiB

3 years ago
  1. <?php
  2. /**
  3. * Atticus Finch Theme Customizer
  4. *
  5. * @package Atticus Finch
  6. */
  7. /**
  8. * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
  9. */
  10. function atticus_finch_customize_preview_js() {
  11. wp_enqueue_script( 'atticus_finch_customizer', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20130508', true );
  12. }
  13. add_action( 'customize_preview_init', 'atticus_finch_customize_preview_js' );
  14. // Add some Customizer stuff
  15. // developer.wordpress.org/themes/advanced-topics/customizer-api/
  16. add_action( 'customize_register', 'atticus_finch_customize_register', 11 );
  17. function atticus_finch_customize_register( $wp_customize ) {
  18. // Add postMessage support for site title and description for the Theme Customizer
  19. $wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
  20. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
  21. $wp_customize->get_setting( 'header_textcolor' )->transport = 'postMessage';
  22. $wp_customize->add_panel( 'atticusfinch', array(
  23. 'title' => __( 'Atticus Finch Theme Options', 'atticus-finch' ),
  24. 'description' => __( 'The Atticus Finch theme has many options. Vist the theme\'s <a href="http://www.example.com/">home page</a> for complete instructions.', 'atticus-finch' ),
  25. 'priority' => 05,
  26. ) );
  27. // Widget Areas
  28. $wp_customize->add_section( 'atticus_finch_widget_areas', array(
  29. 'title' => __( 'Widget Areas', 'atticus-finch' ),
  30. 'capability' => 'edit_theme_options',
  31. 'priority' => 30,
  32. 'description' => __( 'Select which action hook widget areas you would like to activate.', 'atticus-finch' ),
  33. 'panel' => 'atticusfinch',
  34. ) );
  35. $wp_customize->add_setting( 'atticus_finch_before_header', array(
  36. 'type' => 'theme_mod',
  37. 'transport' => 'postMessage',
  38. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  39. ) );
  40. $wp_customize->add_control( 'atticus_finch_before_header', array(
  41. 'section' => 'atticus_finch_widget_areas',
  42. 'type' => 'checkbox',
  43. 'label' => __( 'Before Header', 'atticus-finch' ),
  44. ) );
  45. $wp_customize->add_setting( 'atticus_finch_after_top_menu', array(
  46. 'type' => 'theme_mod',
  47. 'transport' => 'postMessage',
  48. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  49. ) );
  50. $wp_customize->add_control( 'atticus_finch_after_top_menu', array(
  51. 'section' => 'atticus_finch_widget_areas',
  52. 'type' => 'checkbox',
  53. 'label' => __( 'After Top Menu', 'atticus-finch' ),
  54. ) );
  55. $wp_customize->add_setting( 'atticus_finch_before_social_media', array(
  56. 'type' => 'theme_mod',
  57. 'transport' => 'postMessage',
  58. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  59. ) );
  60. $wp_customize->add_control( 'atticus_finch_before_social_media', array(
  61. 'section' => 'atticus_finch_widget_areas',
  62. 'type' => 'checkbox',
  63. 'label' => __( 'Before Social Media', 'atticus-finch' ),
  64. ) );
  65. $wp_customize->add_setting( 'atticus_finch_before_primary_menu', array(
  66. 'type' => 'theme_mod',
  67. 'transport' => 'postMessage',
  68. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  69. ) );
  70. $wp_customize->add_control( 'atticus_finch_before_primary_menu', array(
  71. 'section' => 'atticus_finch_widget_areas',
  72. 'type' => 'checkbox',
  73. 'label' => __( 'Before Primary Menu', 'atticus-finch' ),
  74. ) );
  75. $wp_customize->add_setting( 'atticus_finch_after_header', array(
  76. 'type' => 'theme_mod',
  77. 'transport' => 'postMessage',
  78. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  79. ) );
  80. $wp_customize->add_control( 'atticus_finch_after_header', array(
  81. 'section' => 'atticus_finch_widget_areas',
  82. 'type' => 'checkbox',
  83. 'label' => __( 'After Header', 'atticus-finch' ),
  84. ) );
  85. $wp_customize->add_setting( 'atticus_finch_container_top', array(
  86. 'type' => 'theme_mod',
  87. 'transport' => 'postMessage',
  88. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  89. ) );
  90. $wp_customize->add_control( 'atticus_finch_container_top', array(
  91. 'section' => 'atticus_finch_widget_areas',
  92. 'type' => 'checkbox',
  93. 'label' => __( 'Top of Container', 'atticus-finch' ),
  94. ) );
  95. $wp_customize->add_setting( 'atticus_finch_before_post_title', array(
  96. 'type' => 'theme_mod',
  97. 'transport' => 'postMessage',
  98. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  99. ) );
  100. $wp_customize->add_control( 'atticus_finch_before_post_title', array(
  101. 'section' => 'atticus_finch_widget_areas',
  102. 'type' => 'checkbox',
  103. 'label' => __( 'Before Post Title', 'atticus-finch' ),
  104. ) );
  105. /*
  106. * We've removed this action hook, but let's leave this control in place
  107. * in case we find a use for it later.
  108. $wp_customize->add_setting( 'atticus_finch_before_post_content', array(
  109. 'type' => 'theme_mod',
  110. 'transport' => 'postMessage',
  111. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  112. ) );
  113. $wp_customize->add_control( 'atticus_finch_before_post_content', array(
  114. 'section' => 'atticus_finch_widget_areas',
  115. 'type' => 'checkbox',
  116. 'label' => __( 'Before Post Content', 'atticus-finch' ),
  117. ) );
  118. */
  119. $wp_customize->add_setting( 'atticus_finch_post_top', array(
  120. 'type' => 'theme_mod',
  121. 'transport' => 'postMessage',
  122. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  123. ) );
  124. $wp_customize->add_control( 'atticus_finch_post_top', array(
  125. 'section' => 'atticus_finch_widget_areas',
  126. 'type' => 'checkbox',
  127. 'label' => __( 'Top of Post', 'atticus-finch' ),
  128. ) );
  129. $wp_customize->add_setting( 'atticus_finch_post_bottom', array(
  130. 'type' => 'theme_mod',
  131. 'transport' => 'postMessage',
  132. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  133. ) );
  134. $wp_customize->add_control( 'atticus_finch_post_bottom', array(
  135. 'section' => 'atticus_finch_widget_areas',
  136. 'type' => 'checkbox',
  137. 'label' => __( 'Bottom of Post', 'atticus-finch' ),
  138. ) );
  139. $wp_customize->add_setting( 'atticus_finch_after_post_content', array(
  140. 'type' => 'theme_mod',
  141. 'transport' => 'postMessage',
  142. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  143. ) );
  144. $wp_customize->add_control( 'atticus_finch_after_post_content', array(
  145. 'section' => 'atticus_finch_widget_areas',
  146. 'type' => 'checkbox',
  147. 'label' => __( 'After Post Content', 'atticus-finch' ),
  148. ) );
  149. $wp_customize->add_setting( 'atticus_finch_before_post_meta', array(
  150. 'type' => 'theme_mod',
  151. 'transport' => 'postMessage',
  152. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  153. ) );
  154. $wp_customize->add_control( 'atticus_finch_before_post_meta', array(
  155. 'section' => 'atticus_finch_widget_areas',
  156. 'type' => 'checkbox',
  157. 'label' => __( 'Before Post Meta', 'atticus-finch' ),
  158. ) );
  159. $wp_customize->add_setting( 'atticus_finch_after_post_meta', array(
  160. 'type' => 'theme_mod',
  161. 'transport' => 'postMessage',
  162. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  163. ) );
  164. $wp_customize->add_control( 'atticus_finch_after_post_meta', array(
  165. 'section' => 'atticus_finch_widget_areas',
  166. 'type' => 'checkbox',
  167. 'label' => __( 'After Post Meta', 'atticus-finch' ),
  168. ) );
  169. $wp_customize->add_setting( 'atticus_finch_before_comments', array(
  170. 'type' => 'theme_mod',
  171. 'transport' => 'postMessage',
  172. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  173. ) );
  174. $wp_customize->add_control( 'atticus_finch_before_comments', array(
  175. 'section' => 'atticus_finch_widget_areas',
  176. 'type' => 'checkbox',
  177. 'label' => __( 'Before Comments', 'atticus-finch' ),
  178. ) );
  179. $wp_customize->add_setting( 'atticus_finch_after_comments', array(
  180. 'type' => 'theme_mod',
  181. 'transport' => 'postMessage',
  182. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  183. ) );
  184. $wp_customize->add_control( 'atticus_finch_after_comments', array(
  185. 'section' => 'atticus_finch_widget_areas',
  186. 'type' => 'checkbox',
  187. 'label' => __( 'After Comments', 'atticus-finch' ),
  188. ) );
  189. $wp_customize->add_setting( 'atticus_finch_before_comment_form', array(
  190. 'type' => 'theme_mod',
  191. 'transport' => 'postMessage',
  192. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  193. ) );
  194. $wp_customize->add_control( 'atticus_finch_before_comment_form', array(
  195. 'section' => 'atticus_finch_widget_areas',
  196. 'type' => 'checkbox',
  197. 'label' => __( 'Before Comment Form', 'atticus-finch' ),
  198. ) );
  199. $wp_customize->add_setting( 'atticus_finch_after_comment_form', array(
  200. 'type' => 'theme_mod',
  201. 'transport' => 'postMessage',
  202. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  203. ) );
  204. $wp_customize->add_control( 'atticus_finch_after_comment_form', array(
  205. 'section' => 'atticus_finch_widget_areas',
  206. 'type' => 'checkbox',
  207. 'label' => __( 'After Comment Form', 'atticus-finch' ),
  208. ) );
  209. $wp_customize->add_setting( 'atticus_finch_container_bottom', array(
  210. 'type' => 'theme_mod',
  211. 'transport' => 'postMessage',
  212. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  213. ) );
  214. $wp_customize->add_control( 'atticus_finch_container_bottom', array(
  215. 'section' => 'atticus_finch_widget_areas',
  216. 'type' => 'checkbox',
  217. 'label' => __( 'Bottom of Container', 'atticus-finch' ),
  218. ) );
  219. $wp_customize->add_setting( 'atticus_finch_before_footer_menu', array(
  220. 'type' => 'theme_mod',
  221. 'transport' => 'postMessage',
  222. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  223. ) );
  224. $wp_customize->add_control( 'atticus_finch_before_footer_menu', array(
  225. 'section' => 'atticus_finch_widget_areas',
  226. 'type' => 'checkbox',
  227. 'label' => __( 'Before Footer Menu', 'atticus-finch' ),
  228. ) );
  229. $wp_customize->add_setting( 'atticus_finch_footer_top', array(
  230. 'type' => 'theme_mod',
  231. 'transport' => 'postMessage',
  232. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  233. ) );
  234. $wp_customize->add_control( 'atticus_finch_footer_top', array(
  235. 'section' => 'atticus_finch_widget_areas',
  236. 'type' => 'checkbox',
  237. 'label' => __( 'Top of Footer', 'atticus-finch' ),
  238. ) );
  239. $wp_customize->add_setting( 'atticus_finch_footer_bottom', array(
  240. 'type' => 'theme_mod',
  241. 'transport' => 'postMessage',
  242. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  243. ) );
  244. $wp_customize->add_control( 'atticus_finch_footer_bottom', array(
  245. 'section' => 'atticus_finch_widget_areas',
  246. 'type' => 'checkbox',
  247. 'label' => __( 'Bottom of Footer', 'atticus-finch' ),
  248. ) );
  249. $wp_customize->add_setting( 'atticus_finch_after_footer', array(
  250. 'type' => 'theme_mod',
  251. 'transport' => 'postMessage',
  252. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  253. ) );
  254. $wp_customize->add_control( 'atticus_finch_after_footer', array(
  255. 'section' => 'atticus_finch_widget_areas',
  256. 'type' => 'checkbox',
  257. 'label' => __( 'After Footer', 'atticus-finch' ),
  258. ) );
  259. // Post Format Title Options
  260. $wp_customize->add_section( 'atticus_finch_post_format_title_options', array(
  261. 'title' => __( 'Post Format Title Options', 'atticus-finch' ),
  262. 'capability' => 'edit_theme_options',
  263. 'priority' => 10,
  264. 'description' => __('Select whether titles should appear for various post formats.', 'atticus-finch'),
  265. 'panel' => 'atticusfinch',
  266. ) );
  267. $wp_customize->add_setting( 'atticus_finch_aside_title', array(
  268. 'type' => 'theme_mod',
  269. 'transport' => 'postMessage',
  270. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  271. ) );
  272. $wp_customize->add_control( 'atticus_finch_aside_title', array(
  273. 'section' => 'atticus_finch_post_format_title_options',
  274. 'type' => 'checkbox',
  275. 'label' => __( 'Display title for asides', 'atticus-finch' ),
  276. ) );
  277. $wp_customize->add_setting( 'atticus_finch_link_title', array(
  278. 'type' => 'theme_mod',
  279. 'transport' => 'postMessage',
  280. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  281. ) );
  282. $wp_customize->add_control( 'atticus_finch_link_title', array(
  283. 'section' => 'atticus_finch_post_format_title_options',
  284. 'type' => 'checkbox',
  285. 'label' => __( 'Display title for links', 'atticus-finch' ),
  286. ) );
  287. $wp_customize->add_setting( 'atticus_finch_quote_title', array(
  288. 'type' => 'theme_mod',
  289. 'transport' => 'postMessage',
  290. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  291. ) );
  292. $wp_customize->add_control( 'atticus_finch_quote_title', array(
  293. 'section' => 'atticus_finch_post_format_title_options',
  294. 'type' => 'checkbox',
  295. 'label' => __( 'Display title for quotes', 'atticus-finch' ),
  296. ) );
  297. $wp_customize->add_setting( 'atticus_finch_status_title', array(
  298. 'type' => 'theme_mod',
  299. 'transport' => 'postMessage',
  300. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  301. ) );
  302. $wp_customize->add_control( 'atticus_finch_status_title', array(
  303. 'section' => 'atticus_finch_post_format_title_options',
  304. 'type' => 'checkbox',
  305. 'label' => __( 'Display title for statuses', 'atticus-finch' ),
  306. ) );
  307. // Post Format Excerpt Options
  308. $wp_customize->add_section( 'atticus_finch_post_format_excerpt_options', array(
  309. 'title' => __( 'Post Format Excerpt Options', 'atticus-finch' ),
  310. 'capability' => 'edit_theme_options',
  311. 'priority' => 20,
  312. 'description' => __('By default, the aside, link, quote, and statu post format will display full content on the home page. You can choose to show excerpts instead.', 'atticus-finch'),
  313. 'panel' => 'atticusfinch',
  314. ) );
  315. $wp_customize->add_setting( 'atticus_finch_aside_excerpt', array(
  316. 'type' => 'theme_mod',
  317. 'transport' => 'postMessage',
  318. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  319. ) );
  320. $wp_customize->add_control( 'atticus_finch_aside_excerpt', array(
  321. 'section' => 'atticus_finch_post_format_excerpt_options',
  322. 'type' => 'checkbox',
  323. 'label' => __( 'Display excerpt for asides', 'atticus-finch' ),
  324. ) );
  325. $wp_customize->add_setting( 'atticus_finch_link_excerpt', array(
  326. 'type' => 'theme_mod',
  327. 'transport' => 'postMessage',
  328. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  329. ) );
  330. $wp_customize->add_control( 'atticus_finch_link_excerpt', array(
  331. 'section' => 'atticus_finch_post_format_excerpt_options',
  332. 'type' => 'checkbox',
  333. 'label' => __( 'Display excerpt for links', 'atticus-finch' ),
  334. ) );
  335. $wp_customize->add_setting( 'atticus_finch_quote_excerpt', array(
  336. 'type' => 'theme_mod',
  337. 'transport' => 'postMessage',
  338. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  339. ) );
  340. $wp_customize->add_control( 'atticus_finch_quote_excerpt', array(
  341. 'section' => 'atticus_finch_post_format_excerpt_options',
  342. 'type' => 'checkbox',
  343. 'label' => __( 'Display excerpt for quotes', 'atticus-finch' ),
  344. ) );
  345. $wp_customize->add_setting( 'atticus_finch_status_excerpt', array(
  346. 'type' => 'theme_mod',
  347. 'transport' => 'postMessage',
  348. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  349. ) );
  350. $wp_customize->add_control( 'atticus_finch_status_excerpt', array(
  351. 'section' => 'atticus_finch_post_format_excerpt_options',
  352. 'type' => 'checkbox',
  353. 'label' => __( 'Display excerpt for statuses', 'atticus-finch' ),
  354. ) );
  355. $default_readmore = __( '&hellip;read more&hellip;', 'atticus-finch' );
  356. $wp_customize->add_setting( 'atticus_finch_readmore', array(
  357. 'type' => 'theme_mod',
  358. 'transport' => 'postMessage',
  359. 'default' => $default_readmore,
  360. 'sanitize_callback' => 'atticus_finch_sanitize_text',
  361. ) );
  362. $wp_customize->add_control( 'atticus_finch_readmore', array(
  363. 'section' => 'atticus_finch_post_format_excerpt_options',
  364. 'type' => 'text',
  365. 'label' => __( 'Text for &lsquo;read more&rsquo; link (in all excerpts)', 'atticus-finch'),
  366. ) );
  367. // Copyright Information
  368. $wp_customize->add_section( 'atticus_finch_copyright', array(
  369. 'title' => __( 'Copyright Information', 'atticus-finch' ),
  370. 'capability' => 'edit_theme_options',
  371. 'priority' => 50,
  372. 'description' => __( 'Copyright information will appear in the footer, and at the bottom of printed pages. (Make sure you have not disabled this function under "Miscellaneous Options")', 'atticus-finch' ),
  373. 'panel' => 'atticusfinch',
  374. ) );
  375. $wp_customize->add_setting( 'atticus_finch_copyright', array(
  376. 'type' => 'theme_mod',
  377. 'transport' => 'postMessage',
  378. 'sanitize_callback' => 'html',
  379. ) );
  380. $default_copyright = '<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" id="cc-button" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a>This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.';
  381. $wp_customize->add_control( 'atticus_finch_copyright', array(
  382. 'section' => 'atticus_finch_copyright',
  383. 'default' => $default_copyright,
  384. 'type' => 'textarea',
  385. 'label' => __( 'Enter your copyright information. (HTML is allowed.)', 'atticus-finch' ),
  386. ) );
  387. // Print Options
  388. $wp_customize->add_section( 'atticus_finch_print', array (
  389. 'title' => __( 'Print Options', 'atticus-finch' ),
  390. 'capability' => 'edit_theme_options',
  391. 'priority' => 40,
  392. 'panel' => 'atticusfinch',
  393. ) );
  394. $wp_customize->add_setting( 'atticus_finch_print_url', array(
  395. 'type' => 'theme_mod',
  396. 'transport' => 'postMessage',
  397. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  398. ) );
  399. $wp_customize->add_control( 'atticus_finch_print_url', array(
  400. 'section' => 'atticus_finch_print',
  401. 'type' => 'checkbox',
  402. 'label' => __( 'Print URL information at end of post', 'atticus-finch' ),
  403. ) );
  404. $wp_customize->add_setting( 'atticus_finch_print_copyright', array(
  405. 'type' => 'theme_mod',
  406. 'transport' => 'postMessage',
  407. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  408. ) );
  409. $wp_customize->add_control( 'atticus_finch_print_copyright', array(
  410. 'section' => 'atticus_finch_print',
  411. 'type' => 'checkbox',
  412. 'label' => __( 'Print copyright information at end of post', 'atticus-finch' ),
  413. ) );
  414. // Social Media Options
  415. $wp_customize->add_section( 'atticus_finch_social_media', array(
  416. 'title' => __( 'Social Media Options', 'atticus-finch' ),
  417. 'capability' => 'edit_theme_options',
  418. 'priority' => 90,
  419. 'panel' => 'atticusfinch',
  420. ) );
  421. $wp_customize->add_setting( 'atticus_finch_rss', array(
  422. 'type' => 'theme_mod',
  423. 'transport' => 'postMessage',
  424. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  425. ) );
  426. $wp_customize->add_control( 'atticus_finch_rss', array(
  427. 'section' => 'atticus_finch_social_media',
  428. 'type' => 'checkbox',
  429. 'label' => __( 'Display link to RSS feed', 'atticus-finch' ),
  430. ) );
  431. $wp_customize->add_setting( 'atticus_finch_twitter', array(
  432. 'type' => 'theme_mod',
  433. 'transport' => 'postMessage',
  434. 'sanitize_callback' => 'atticus_finch_sanitize_url',
  435. ) );
  436. $wp_customize->add_control( 'atticus_finch_twitter', array(
  437. 'section' => 'atticus_finch_social_media',
  438. 'type' => 'url',
  439. 'label' => __( 'Enter Twitter URL', 'atticus-finch'),
  440. ) );
  441. $wp_customize->add_setting( 'atticus_finch_twitter2', array(
  442. 'type' => 'theme_mod',
  443. 'transport' => 'postMessage',
  444. 'sanitize_callback' => 'atticus_finch_sanitize_url',
  445. ) );
  446. $wp_customize->add_control( 'atticus_finch_twitter2', array(
  447. 'section' => 'atticus_finch_social_media',
  448. 'type' => 'url',
  449. 'label' => __( 'Enter second Twitter URL', 'atticus-finch'),
  450. ) );
  451. $wp_customize->add_setting( 'atticus_finch_facebook', array(
  452. 'type' => 'theme_mod',
  453. 'transport' => 'postMessage',
  454. 'sanitize_callback' => 'atticus_finch_sanitize_url',
  455. ) );
  456. $wp_customize->add_control( 'atticus_finch_facebook', array(
  457. 'section' => 'atticus_finch_social_media',
  458. 'type' => 'url',
  459. 'label' => __( 'Enter Facebook URL', 'atticus-finch'),
  460. ) );
  461. $wp_customize->add_setting( 'atticus_finch_instagram', array(
  462. 'type' => 'theme_mod',
  463. 'transport' => 'postMessage',
  464. 'sanitize_callback' => 'atticus_finch_sanitize_url',
  465. ) );
  466. $wp_customize->add_control( 'atticus_finch_instagram', array(
  467. 'section' => 'atticus_finch_social_media',
  468. 'type' => 'text',
  469. 'label' => __( 'Enter Instagram URL', 'atticus-finch'),
  470. ) );
  471. $wp_customize->add_setting( 'atticus_finch_youtube', array(
  472. 'type' => 'theme_mod',
  473. 'transport' => 'postMessage',
  474. 'sanitize_callback' => 'atticus_finch_sanitize_url',
  475. ) );
  476. $wp_customize->add_control( 'atticus_finch_youtube', array(
  477. 'section' => 'atticus_finch_social_media',
  478. 'type' => 'url',
  479. 'label' => __( 'Enter YouTube URL', 'atticus-finch'),
  480. ) );
  481. $wp_customize->add_setting( 'atticus_finch_pinterest', array(
  482. 'type' => 'theme_mod',
  483. 'transport' => 'postMessage',
  484. 'sanitize_callback' => 'atticus_finch_sanitize_url',
  485. ) );
  486. $wp_customize->add_control( 'atticus_finch_pinterest', array(
  487. 'section' => 'atticus_finch_social_media',
  488. 'type' => 'url',
  489. 'label' => __( 'Enter Pinterest Profile URL', 'atticus-finch'),
  490. ) );
  491. $wp_customize->add_setting( 'atticus_finch_amazon', array(
  492. 'type' => 'theme_mod',
  493. 'transport' => 'postMessage',
  494. 'sanitize_callback' => 'atticus_finch_sanitize_url',
  495. ) );
  496. $wp_customize->add_control( 'atticus_finch_amazon', array(
  497. 'section' => 'atticus_finch_social_media',
  498. 'type' => 'url',
  499. 'label' => __( 'Enter Amazon Wish List URL', 'atticus-finch'),
  500. ) );
  501. // Mobile Menu Options
  502. $wp_customize->add_section( 'atticus_finch_mobile_menu_options', array(
  503. 'title' => __( 'Mobile Menu Options', 'atticus-finch' ),
  504. 'capability' => 'edit_theme_options',
  505. 'priority' => 110,
  506. 'description' => __('Menu settings for mobile appearance. <b>Note:</b> The breakpoint settings will override the "mobile breakpoint" setting.', 'atticus-finch'),
  507. 'panel' => 'atticusfinch',
  508. ) );
  509. // Top Menu Options
  510. $wp_customize->add_setting( 'atticus_finch_top_menu_name', array(
  511. 'type' => 'theme_mod',
  512. 'transport' => 'postMessage',
  513. 'sanitize_callback' => 'atticus_finch_sanitize_text',
  514. ) );
  515. $wp_customize->add_control( 'atticus_finch_top_menu_name', array(
  516. 'section' => 'atticus_finch_mobile_menu_options',
  517. 'type' => 'text',
  518. 'label' => __( 'Mobile display name for top menu', 'atticus-finch' ),
  519. ) );
  520. $wp_customize->add_setting( 'atticus_finch_top_menu_type', array(
  521. 'type' => 'theme_mod',
  522. 'transport' => 'postMessage',
  523. 'sanitize_callback' => 'atticus_finch_sanitize_mobile_menu_type',
  524. 'default' => 'select',
  525. ) );
  526. $wp_customize->add_control( 'atticus_finch_top_menu_type', array(
  527. 'section' => 'atticus_finch_mobile_menu_options',
  528. 'type' => 'select',
  529. 'choices' => array(
  530. 'select' => 'Select Menu',
  531. 'dropdown' => 'Flat Menu',
  532. 'multitoggle' => 'Dropdown Menu',
  533. ),
  534. 'label' => __( 'Display the top menu as', 'atticus-finch' ),
  535. ) );
  536. $wp_customize->add_setting( 'atticus_finch_top_menu_breakpoint', array(
  537. 'type' => 'theme_mod',
  538. 'transport' => 'postMessage',
  539. 'sanitize_callback' => 'atticus_finch_sanitize_int',
  540. 'default' => 640,
  541. ) );
  542. $wp_customize->add_control( 'atticus_finch_top_menu_breakpoint', array(
  543. 'section' => 'atticus_finch_mobile_menu_options',
  544. 'type' => 'integer',
  545. 'label' => __( 'Breakpoint to display top menu as mobile', 'atticus-finch' ),
  546. ) );
  547. // Main Menu Options
  548. $wp_customize->add_setting( 'atticus_finch_main_menu_name', array(
  549. 'type' => 'theme_mod',
  550. 'transport' => 'postMessage',
  551. 'sanitize_callback' => 'atticus_finch_sanitize_text',
  552. ) );
  553. $wp_customize->add_control( 'atticus_finch_main_menu_name', array(
  554. 'section' => 'atticus_finch_mobile_menu_options',
  555. 'type' => 'text',
  556. 'label' => __( 'Mobile display name for main menu', 'atticus-finch' ),
  557. ) );
  558. $wp_customize->add_setting( 'atticus_finch_main_menu_type', array(
  559. 'type' => 'theme_mod',
  560. 'transport' => 'postMessage',
  561. 'sanitize_callback' => 'atticus_finch_sanitize_mobile_menu_type',
  562. 'default' => 'select',
  563. ) );
  564. $wp_customize->add_control( 'atticus_finch_main_menu_type', array(
  565. 'section' => 'atticus_finch_mobile_menu_options',
  566. 'type' => 'select',
  567. 'choices' => array(
  568. 'select' => 'Select Menu',
  569. 'dropdown' => 'Flat Menu',
  570. 'multitoggle' => 'Dropdown Menu',
  571. ),
  572. 'label' => __( 'Display the menu menu as', 'atticus-finch' ),
  573. ) );
  574. $wp_customize->add_setting( 'atticus_finch_main_menu_breakpoint', array(
  575. 'type' => 'theme_mod',
  576. 'transport' => 'postMessage',
  577. 'sanitize_callback' => 'atticus_finch_sanitize_int',
  578. 'default' => 640,
  579. ) );
  580. $wp_customize->add_control( 'atticus_finch_main_menu_breakpoint', array(
  581. 'section' => 'atticus_finch_mobile_menu_options',
  582. 'type' => 'integer',
  583. 'label' => __( 'Breakpoint to display main menu as mobile', 'atticus-finch' ),
  584. ) );
  585. // Footer Menu Options
  586. $wp_customize->add_setting( 'atticus_finch_footer_menu_name', array(
  587. 'type' => 'theme_mod',
  588. 'transport' => 'postMessage',
  589. 'sanitize_callback' => 'atticus_finch_sanitize_text',
  590. ) );
  591. $wp_customize->add_control( 'atticus_finch_footer_menu_name', array(
  592. 'section' => 'atticus_finch_mobile_menu_options',
  593. 'type' => 'text',
  594. 'label' => __( 'Mobile display name for footer menu', 'atticus-finch' ),
  595. ) );
  596. $wp_customize->add_setting( 'atticus_finch_footer_menu_type', array(
  597. 'type' => 'theme_mod',
  598. 'transport' => 'postMessage',
  599. 'sanitize_callback' => 'atticus_finch_sanitize_mobile_menu_type',
  600. 'default' => 'select',
  601. ) );
  602. $wp_customize->add_control( 'atticus_finch_footer_menu_type', array(
  603. 'section' => 'atticus_finch_mobile_menu_options',
  604. 'type' => 'select',
  605. 'choices' => array(
  606. 'select' => 'Select Menu',
  607. 'dropdown' => 'Flat Menu',
  608. 'multitoggle' => 'Dropdown Menu',
  609. ),
  610. 'label' => __( 'Display the footer menu as', 'atticus-finch' ),
  611. ) );
  612. $wp_customize->add_setting( 'atticus_finch_footer_menu_breakpoint', array(
  613. 'type' => 'theme_mod',
  614. 'transport' => 'postMessage',
  615. 'sanitize_callback' => 'atticus_finch_sanitize_int',
  616. 'default' => 640,
  617. ) );
  618. $wp_customize->add_control( 'atticus_finch_footer_menu_breakpoint', array(
  619. 'section' => 'atticus_finch_mobile_menu_options',
  620. 'type' => 'integer',
  621. 'label' => __( 'Breakpoint to display footer menu as mobile', 'atticus-finch' ),
  622. ) );
  623. // Mobile Options Options
  624. $wp_customize->add_section( 'atticus_finch_mobile', array(
  625. 'title' => __( 'Mobile Options', 'atticus-finch' ),
  626. 'capability' => 'edit_theme_options',
  627. 'priority' => 100,
  628. 'panel' => 'atticusfinch',
  629. 'description' => 'Fine-tune your mobile appearance',
  630. ) );
  631. $wp_customize->add_setting( 'atticus_finch_mobile_breakpoint', array(
  632. 'type' => 'theme_mod',
  633. 'transport' => 'postMessage',
  634. 'default' => '640',
  635. 'sanitize_callback' => 'atticus_finch_sanitize_int',
  636. ) );
  637. $wp_customize->add_control( 'atticus_finch_mobile_breakpoint', array(
  638. 'section' => 'atticus_finch_mobile',
  639. 'type' => 'text',
  640. 'label' => __( 'Breakpoint to display mobile version of theme', 'atticus-finch' ),
  641. ) );
  642. $wp_customize->add_setting( 'atticus_finch_post_top_link', array(
  643. 'type' => 'theme_mod',
  644. 'transport' => 'postMessage',
  645. 'default' => '0',
  646. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  647. ) );
  648. $wp_customize->add_control( 'atticus_finch_post_top_link', array(
  649. 'section' => 'atticus_finch_mobile',
  650. 'type' => 'checkbox',
  651. 'label' => __( 'Display \'Return to Top\' link after post content', 'atticus-finch' ),
  652. ) );
  653. $wp_customize->add_setting( 'atticus_finch_footer_top_link', array(
  654. 'type' => 'theme_mod',
  655. 'transport' => 'postMessage',
  656. 'default' => '0',
  657. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  658. ) );
  659. $wp_customize->add_control( 'atticus_finch_footer_top_link', array(
  660. 'section' => 'atticus_finch_mobile',
  661. 'type' => 'checkbox',
  662. 'label' => __( 'Display \'Return to Top\' link before footer content', 'atticus-finch' ),
  663. ) );
  664. // Miscellaneous Options
  665. $wp_customize->add_section( 'atticus_finch_misc', array(
  666. 'title' => __( 'Miscellaneous Options', 'atticus-finch' ),
  667. 'capability' => 'edit_theme_options',
  668. 'priority' => 200,
  669. 'panel' => 'atticusfinch',
  670. ) );
  671. $wp_customize->add_setting( 'atticus_finch_display_copyright', array(
  672. 'type' => 'theme_mod',
  673. 'transport' => 'postMessage',
  674. 'default' => '1',
  675. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  676. ) );
  677. $wp_customize->add_control( 'atticus_finch_display_copyright', array(
  678. 'section' => 'atticus_finch_misc',
  679. 'type' => 'checkbox',
  680. 'label' => __( 'Display copyright information in footer', 'atticus-finch' ),
  681. ) );
  682. $wp_customize->add_setting( 'atticus_finch_display_credits', array(
  683. 'type' => 'theme_mod',
  684. 'transport' => 'postMessage',
  685. 'default' => '1',
  686. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  687. ) );
  688. $wp_customize->add_control( 'atticus_finch_display_credits', array(
  689. 'section' => 'atticus_finch_misc',
  690. 'type' => 'checkbox',
  691. 'label' => __( 'Display developer credits in footer', 'atticus-finch' ),
  692. ) );
  693. $wp_customize->add_setting( 'atticus_finch_edit_post_link', array(
  694. 'type' => 'theme_mod',
  695. 'transport' => 'postMessage',
  696. 'default' => '1',
  697. 'sanitize_callback' => 'atticus_finch_sanitize_checkbox',
  698. ) );
  699. $wp_customize->add_control( 'atticus_finch_edit_post_link', array(
  700. 'section' => 'atticus_finch_misc',
  701. 'type' => 'checkbox',
  702. 'label' => __( 'Display "Edit this post" link if user is logged in', 'atticus-finch' ),
  703. ) );
  704. $wp_customize->add_setting( 'atticus_finch_excerpt_length', array(
  705. 'type' => 'theme_mod',
  706. 'transport' => 'postMessage',
  707. 'default' => '20',
  708. 'sanitize_callback' => 'atticus_finch_sanitize_excerpt',
  709. ) );
  710. $wp_customize->add_control( 'atticus_finch_excerpt_length', array(
  711. 'section' => 'atticus_finch_misc',
  712. 'type' => 'text',
  713. 'label' => __( 'Excerpt length in number of words (maximum = 100)', 'atticus-finch' ),
  714. ) );
  715. // Preview some of our options
  716. /*
  717. if ( $wp_customize->is_preview() && ! is_admin() )
  718. add_action( 'wp_footer', 'atticus_finch_customize_preview', 21);
  719. function themename_customize_preview() {
  720. ?>
  721. <script type="text/javascript">
  722. ( function( $ ){
  723. wp.customize('setting_name',function( value ) {
  724. value.bind(function(to) {
  725. $('.posttitle').css('color', to ? to : '' );
  726. });
  727. });
  728. } )( jQuery )
  729. </script>
  730. <?php
  731. }
  732. */
  733. } // End register function
  734. // Sanitizer Functions
  735. function atticus_finch_sanitize_checkbox( $input ) {
  736. if ( $input == 1 ) {
  737. return 1;
  738. } else {
  739. return '';
  740. }
  741. }
  742. function atticus_finch_sanitize_text( $input ) {
  743. return wp_kses_post( force_balance_tags( $input ) );
  744. }
  745. function atticus_finch_sanitize_excerpt( $input ) {
  746. $input = absint( $input );
  747. if ( $input > 100 ) { $input = 100; }
  748. return $input;
  749. }
  750. function atticus_finch_sanitize_html( $input ) {
  751. wp_kses($input,
  752. array(),
  753. array(
  754. 'http' => array(),
  755. 'https' => array(),
  756. )
  757. );
  758. }
  759. function atticus_finch_sanitize_url( $url ) {
  760. return esc_url_raw( $url );
  761. }
  762. function atticus_finch_sanitize_mobile_menu_type( $input ){
  763. $valid = array(
  764. 'select' => 'Select Menu',
  765. 'dropdown' => 'Flat Menu',
  766. 'multitoggle' => 'Dropdown Menu',
  767. );
  768. if ( array_key_exists( $input, $valid ) ) {
  769. return $input;
  770. } else {
  771. return '';
  772. }
  773. }
  774. function atticus_finch_sanitize_int( $input ){
  775. if( is_numeric( $input) ) {
  776. return intval( $input );
  777. }
  778. }