PageRenderTime 56ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/themes/catch-box/inc/theme-options.php

https://github.com/ActivateNY/activateny.org
PHP | 1472 lines | 976 code | 204 blank | 292 comment | 149 complexity | 5f4a986b06eebbf77f1c14c54c17dec5 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Catch Box Theme Options
  4. *
  5. * @package Catch Themes
  6. * @subpackage Catch_Box
  7. * @since Catch Box 1.0
  8. */
  9. /**
  10. * Properly enqueue styles and scripts for our theme options page.
  11. *
  12. * This function is attached to the admin_enqueue_scripts action hook.
  13. *
  14. * @since Catch Box 1.0
  15. *
  16. */
  17. function catchbox_admin_enqueue_scripts( $hook_suffix ) {
  18. wp_enqueue_style( 'catchbox-theme-options', get_template_directory_uri() . '/inc/theme-options.css', false, '2011-04-28' );
  19. wp_enqueue_script( 'catchbox-theme-options', get_template_directory_uri() . '/inc/theme-options.js', array( 'farbtastic' ), '2011-06-10' );
  20. wp_enqueue_style( 'farbtastic' );
  21. wp_enqueue_script( 'simplecatch_upload', get_template_directory_uri().'/inc/add_image_scripts.js', array( 'jquery','media-upload','thickbox' ) );
  22. wp_enqueue_style( 'thickbox' );
  23. }
  24. add_action( 'admin_print_styles-appearance_page_theme_options', 'catchbox_admin_enqueue_scripts' );
  25. add_action( 'admin_print_styles-appearance_page_slider_options', 'catchbox_admin_enqueue_scripts' );
  26. add_action( 'admin_print_styles-appearance_page_social_links', 'catchbox_admin_enqueue_scripts' );
  27. add_action( 'admin_print_styles-appearance_page_webmaster_tools', 'catchbox_admin_enqueue_scripts' );
  28. /**
  29. * Register the form setting for our catchbox_options array.
  30. *
  31. * This function is attached to the admin_init action hook.
  32. *
  33. * This call to register_setting() registers a validation callback, catchbox_theme_options_validate(),
  34. * which is used when the option is saved, to ensure that our option values are complete, properly
  35. * formatted, and safe.
  36. *
  37. * We also use this function to add our theme option if it doesn't already exist.
  38. *
  39. * @since Catch Box 1.0
  40. */
  41. function catchbox_theme_options_init() {
  42. // If we have no options in the database, let's add them now.
  43. if ( false === catchbox_get_theme_options() )
  44. add_option( 'catchbox_theme_options', catchbox_get_default_theme_options() );
  45. register_setting(
  46. 'catchbox_options', // Options group, see settings_fields() call in catchbox_theme_options_render_page()
  47. 'catchbox_theme_options', // Database option, see catchbox_get_theme_options()
  48. 'catchbox_theme_options_validate' // The sanitization callback, see catchbox_theme_options_validate()
  49. );
  50. register_setting(
  51. 'catchbox_options_slider', // Options group, see settings_fields() call in catchbox_theme_options_render_page()
  52. 'catchbox_options_slider', // Database option, see catchbox_get_theme_options()
  53. 'catchbox_options_validation' // The sanitization callback, see catchbox_theme_options_validate()
  54. );
  55. register_setting(
  56. 'catchbox_options_webmaster', // Options group, see settings_fields() call in catchbox_theme_options_render_page()
  57. 'catchbox_options_webmaster', // Database option, see catchbox_get_theme_options()
  58. 'catchbox_options_webmaster_validation' // The sanitization callback, see catchbox_theme_options_validate()
  59. );
  60. register_setting(
  61. 'catchbox_options_social_links', // Options group, see settings_fields() call in catchbox_theme_options_render_page()
  62. 'catchbox_options_social_links', // Database option, see catchbox_get_theme_options()
  63. 'catchbox_options_social_links_validation' // The sanitization callback, see catchbox_theme_options_validate()
  64. );
  65. // Register our settings field group
  66. add_settings_section(
  67. 'general', // Unique identifier for the settings section
  68. '', // Section title (we don't want one)
  69. '__return_false', // Section callback (we don't want anything)
  70. 'theme_options' // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  71. );
  72. // Register our individual settings fields
  73. add_settings_field(
  74. 'favicon', // Unique identifier for the field for this section
  75. __( 'Favicon URL', 'catchbox' ), // Setting field label
  76. 'catchbox_settings_field_favicon', // Function that renders the settings field
  77. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  78. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  79. );
  80. // Register our individual settings fields
  81. add_settings_field(
  82. 'webclip', // Unique identifier for the field for this section
  83. __( 'Web Clip Icon URL', 'catchbox' ), // Setting field label
  84. 'catchbox_settings_field_webclip', // Function that renders the settings field
  85. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  86. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  87. );
  88. // Register our individual settings fields
  89. add_settings_field(
  90. 'color_scheme', // Unique identifier for the field for this section
  91. __( 'Color Scheme', 'catchbox' ), // Setting field label
  92. 'catchbox_settings_field_color_scheme', // Function that renders the settings field
  93. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  94. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  95. );
  96. add_settings_field(
  97. 'link_color', // Unique identifier for the field for this section
  98. __( 'Link Color', 'catchbox' ), // Setting field label
  99. 'catchbox_settings_field_link_color', // Function that renders the settings field
  100. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  101. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  102. );
  103. add_settings_field(
  104. 'layout', // Unique identifier for the field for this section
  105. __( 'Default Layout', 'catchbox' ), // Setting field label
  106. 'catchbox_settings_field_layout', // Function that renders the settings field
  107. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  108. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  109. );
  110. add_settings_field(
  111. 'content_layout', // Unique identifier for the settings section
  112. __( 'Content layout', 'catchbox' ), // Setting field label
  113. 'catchbox_settings_field_content_scheme', // Function that renders the settings field
  114. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  115. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  116. );
  117. add_settings_field(
  118. 'excerpt_length', // Unique identifier for the settings section
  119. __( 'Excerpt Length in Words', 'catchbox' ), // Setting field label
  120. 'catchbox_settings_field_excerpt_length', // Function that renders the settings field
  121. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  122. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  123. );
  124. add_settings_field(
  125. 'feed_redirect', // Unique identifier for the settings section
  126. __( 'Feed Redirect URL', 'catchbox' ), // Setting field label
  127. 'catchbox_settings_field_feed_redirect', // Function that renders the settings field
  128. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  129. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  130. );
  131. add_settings_field(
  132. 'disable_header_search', // Unique identifier for the settings section
  133. __( 'Disable Search in Header', 'catchbox' ), // Setting field label
  134. 'catchbox_settings_field_disable_header_search', // Function that renders the settings field
  135. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  136. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  137. );
  138. add_settings_field(
  139. 'custom_css', // Unique identifier for the settings section
  140. __( 'Custom CSS Styles', 'catchbox' ), // Setting field label
  141. 'catchbox_settings_field_custom_css', // Function that renders the settings field
  142. 'theme_options', // Menu slug, used to uniquely identify the page; see catchbox_theme_options_add_page()
  143. 'general' // Settings section. Same as the first argument in the add_settings_section() above
  144. );
  145. }
  146. add_action( 'admin_init', 'catchbox_theme_options_init' );
  147. /**
  148. * Change the capability required to save the 'catchbox_options' options group.
  149. *
  150. * @see catchbox_theme_options_init() First parameter to register_setting() is the name of the options group.
  151. * @see catchbox_theme_options_add_page() The edit_theme_options capability is used for viewing the page.
  152. *
  153. * By default, the options groups for all registered settings require the manage_options capability.
  154. * This filter is required to change our theme options page to edit_theme_options instead.
  155. * By default, only administrators have either of these capabilities, but the desire here is
  156. * to allow for finer-grained control for roles and users.
  157. *
  158. * @param string $capability The capability used for the page, which is manage_options by default.
  159. * @return string The capability to actually use.
  160. */
  161. function catchbox_option_page_capability( $capability ) {
  162. return 'edit_theme_options';
  163. }
  164. add_filter( 'option_page_capability_catchbox_options', 'catchbox_option_page_capability' );
  165. /**
  166. * Add our theme options page to the admin menu, including some help documentation.
  167. *
  168. * This function is attached to the admin_menu action hook.
  169. *
  170. * @since Catch Box 1.0
  171. */
  172. function catchbox_theme_options_add_page() {
  173. $theme_page = add_theme_page(
  174. __( 'Theme Options', 'catchbox' ), // Name of page
  175. __( 'Theme Options', 'catchbox' ), // Label in menu
  176. 'edit_theme_options', // Capability required
  177. 'theme_options', // Menu slug, used to uniquely identify the page
  178. 'catchbox_theme_options_render_page' // Function that renders the options page
  179. );
  180. $slider_options = add_theme_page(
  181. __( 'Featured Slider', 'catchbox' ), // Name of page
  182. __( 'Featured Slider', 'catchbox' ), // Label in menu
  183. 'edit_theme_options', // Capability required
  184. 'slider_options', // Menu slug, used to uniquely identify the page
  185. 'catchbox_options_slider_page' // Function that renders the options page
  186. );
  187. $social_link_options = add_theme_page(
  188. __( 'Social Links', 'catchbox' ), // Name of page
  189. __( 'Social Links', 'catchbox' ), // Label in menu
  190. 'edit_theme_options', // Capability required
  191. 'social_links', // Menu slug, used to uniquely identify the page
  192. 'catchbox_options_social_links' // Function that renders the options page
  193. );
  194. $webmaster_tool_options = add_theme_page(
  195. __( 'Webmaster Tools', 'catchbox' ), // Name of page
  196. __( 'Webmaster Tools', 'catchbox' ), // Label in menu
  197. 'edit_theme_options', // Capability required
  198. 'webmaster_tools', // Menu slug, used to uniquely identify the page
  199. 'catchbox_options_webmaster_tools' // Function that renders the options page
  200. );
  201. if ( ! $theme_page )
  202. return;
  203. add_action( "load-$theme_page", 'catchbox_theme_options_help' );
  204. add_action( "load-$slider_options", 'catchbox_slider_options_help' );
  205. }
  206. add_action( 'admin_menu', 'catchbox_theme_options_add_page' );
  207. function catchbox_theme_options_help() {
  208. $help = '<p>' . __( 'Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Catch Box, provides the following Theme Options:', 'catchbox' ) . '</p>' .
  209. '<ol>' .
  210. '<li>' . __( '<strong>Color Scheme</strong>: You can choose a color palette of "Light" (light background with dark text) or "Dark" (dark background with light text) for your site.', 'catchbox' ) . '</li>' .
  211. '<li>' . __( '<strong>Link Color</strong>: You can choose the color used for text links on your site. You can enter the HTML color or hex code, or you can choose visually by clicking the "Select a Color" button to pick from a color wheel.', 'catchbox' ) . '</li>' .
  212. '<li>' . __( '<strong>Default Layout</strong>: You can choose if you want your site&#8217;s default layout to have a sidebar on the left, the right, or not at all.', 'catchbox' ) . '</li>' .
  213. '</ol>' .
  214. '<p>' . __( 'Remember to click "Save Changes" to save any changes you have made to the theme options.', 'catchbox' ) . '</p>';
  215. $sidebar = '<p><strong>' . __( 'For more information:', 'catchbox' ) . '</strong></p>' .
  216. '<p>' . __( '<a href="http://codex.wordpress.org/Appearance_Theme_Options_Screen" target="_blank">Documentation on Theme Options</a>', 'catchbox' ) . '</p>' .
  217. '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>', 'catchbox' ) . '</p>';
  218. $screen = get_current_screen();
  219. if ( method_exists( $screen, 'add_help_tab' ) ) {
  220. // WordPress 3.3
  221. $screen->add_help_tab( array(
  222. 'title' => __( 'Overview', 'catchbox' ),
  223. 'id' => 'theme-options-help',
  224. 'content' => $help,
  225. )
  226. );
  227. $screen->set_help_sidebar( $sidebar );
  228. }
  229. }
  230. function catchbox_slider_options_help() {
  231. $help = '<p>' . __( 'Slider Some themes provide customization options that are grouped together on a Theme Options screen. If you change themes, options may change or disappear, as they are theme-specific. Your current theme, Catch Box, provides the following Theme Options:', 'catchbox' ) . '</p>' .
  232. '<ol>' .
  233. '<li>' . __( '<strong>Color Scheme</strong>: You can choose a color palette of "Light" (light background with dark text) or "Dark" (dark background with light text) for your site.', 'catchbox' ) . '</li>' .
  234. '<li>' . __( '<strong>Link Color</strong>: You can choose the color used for text links on your site. You can enter the HTML color or hex code, or you can choose visually by clicking the "Select a Color" button to pick from a color wheel.', 'catchbox' ) . '</li>' .
  235. '<li>' . __( '<strong>Default Layout</strong>: You can choose if you want your site&#8217;s default layout to have a sidebar on the left, the right, or not at all.', 'catchbox' ) . '</li>' .
  236. '</ol>' .
  237. '<p>' . __( 'Remember to click "Save Changes" to save any changes you have made to the theme options.', 'catchbox' ) . '</p>';
  238. $screen = get_current_screen();
  239. if ( method_exists( $screen, 'add_help_tab' ) ) {
  240. // WordPress 3.3
  241. $screen->add_help_tab( array(
  242. 'title' => __( 'Overview', 'catchbox' ),
  243. 'id' => 'slider-options-help',
  244. 'content' => $help,
  245. )
  246. );
  247. }
  248. }
  249. /**
  250. * Renders the favicon url setting field.
  251. *
  252. * @since Catch Box 1.6
  253. */
  254. function catchbox_settings_field_favicon() {
  255. $options = catchbox_get_theme_options();
  256. ?>
  257. <input class="upload-url" type="text" name="catchbox_theme_options[fav_icon]" id="fav-icon" size="65" value="<?php if ( isset( $options[ 'fav_icon' ] ) ) echo esc_attr( $options[ 'fav_icon'] ); ?>" />
  258. <input id="st_upload_button" class="st_upload_button button" name="wsl-image-add" type="button" value="<?php esc_attr_e( 'Add/Change Favicon','simplecatch' );?>" />
  259. <?php
  260. }
  261. /**
  262. * Renders the favicon url setting field.
  263. *
  264. * @since Catch Box 2.0.3
  265. */
  266. function catchbox_settings_field_webclip() {
  267. $options = catchbox_get_theme_options();
  268. ?>
  269. <input class="upload-url" type="text" name="catchbox_theme_options[web_clip]" id="web-clip" size="65" value="<?php if ( isset( $options[ 'web_clip' ] ) ) echo esc_attr( $options[ 'web_clip'] ); ?>" />
  270. <input id="st_upload_button" class="st_upload_button button" name="wsl-image-add" type="button" value="<?php esc_attr_e( 'Add/Change Web Clip Icon','simplecatch' );?>" />
  271. <?php
  272. }
  273. /**
  274. * Returns an array of color schemes registered for Catch Box.
  275. *
  276. * @since Catch Box 1.0
  277. */
  278. function catchbox_color_schemes() {
  279. $color_scheme_options = array(
  280. 'light' => array(
  281. 'value' => 'light',
  282. 'label' => __( 'Light', 'catchbox' ),
  283. 'thumbnail' => get_template_directory_uri() . '/inc/images/light.png',
  284. 'default_link_color' => '#1b8be0',
  285. ),
  286. 'dark' => array(
  287. 'value' => 'dark',
  288. 'label' => __( 'Dark', 'catchbox' ),
  289. 'thumbnail' => get_template_directory_uri() . '/inc/images/dark.png',
  290. 'default_link_color' => '#e4741f',
  291. ),
  292. 'blue' => array(
  293. 'value' => 'blue',
  294. 'label' => __( 'Blue', 'catchbox' ),
  295. 'thumbnail' => get_template_directory_uri() . '/inc/images/blue.png',
  296. 'default_link_color' => '#326693',
  297. ),
  298. );
  299. return apply_filters( 'catchbox_color_schemes', $color_scheme_options );
  300. }
  301. /**
  302. * Returns an array of layout options registered for Catch Box.
  303. *
  304. * @since Catch Box 1.0
  305. */
  306. function catchbox_layouts() {
  307. $layout_options = array(
  308. 'content-sidebar' => array(
  309. 'value' => 'content-sidebar',
  310. 'label' => __( 'Content on left', 'catchbox' ),
  311. 'thumbnail' => get_template_directory_uri() . '/inc/images/content-sidebar.png',
  312. ),
  313. 'sidebar-content' => array(
  314. 'value' => 'sidebar-content',
  315. 'label' => __( 'Content on right', 'catchbox' ),
  316. 'thumbnail' => get_template_directory_uri() . '/inc/images/sidebar-content.png',
  317. ),
  318. 'content-onecolumn' => array(
  319. 'value' => 'content-onecolumn',
  320. 'label' => __( 'One-column, no sidebar', 'catchbox' ),
  321. 'thumbnail' => get_template_directory_uri() . '/inc/images/content.png',
  322. ),
  323. );
  324. return apply_filters( 'catchbox_layouts', $layout_options );
  325. }
  326. /**
  327. * Returns an array of content layout options registered for Catch Box.
  328. *
  329. * @since Catch Box 1.0
  330. */
  331. function catchbox_content_layout() {
  332. $content_options = array(
  333. 'excerpt' => array(
  334. 'value' => 'excerpt',
  335. 'label' => __( 'Show excerpt', 'catchbox' ),
  336. 'thumbnail' => get_template_directory_uri() . '/inc/images/excerpt.png',
  337. ),
  338. 'full-content' => array(
  339. 'value' => 'full-content',
  340. 'label' => __( 'Show full content', 'catchbox' ),
  341. 'thumbnail' => get_template_directory_uri() . '/inc/images/full-content.png',
  342. )
  343. );
  344. return apply_filters( 'catchbox_content_layouts', $content_options );
  345. }
  346. /**
  347. * Returns the default options for Catch Box.
  348. *
  349. * @since Catch Box 1.0
  350. */
  351. function catchbox_get_default_theme_options() {
  352. $default_theme_options = array(
  353. 'excerpt_length' => 40,
  354. 'color_scheme' => 'light',
  355. 'link_color' => catchbox_get_default_link_color( 'light' ),
  356. 'theme_layout' => 'content-sidebar',
  357. 'content_layout' => 'excerpt',
  358. 'disable_header_search' => '0'
  359. );
  360. if ( is_rtl() )
  361. $default_theme_options['theme_layout'] = 'sidebar-content';
  362. return apply_filters( 'catchbox_default_theme_options', $default_theme_options );
  363. }
  364. /**
  365. * Returns the default link color for Catch Box, based on color scheme.
  366. *
  367. * @since Catch Box 1.0
  368. *
  369. * @param $string $color_scheme Color scheme. Defaults to the active color scheme.
  370. * @return $string Color.
  371. */
  372. function catchbox_get_default_link_color( $color_scheme = null ) {
  373. if ( null === $color_scheme ) {
  374. $options = catchbox_get_theme_options();
  375. $color_scheme = $options['color_scheme'];
  376. }
  377. $color_schemes = catchbox_color_schemes();
  378. if ( ! isset( $color_schemes[ $color_scheme ] ) )
  379. return false;
  380. return $color_schemes[ $color_scheme ]['default_link_color'];
  381. }
  382. /**
  383. * Returns the options array for Catch Box.
  384. *
  385. * @since Catch Box 1.0
  386. */
  387. function catchbox_get_theme_options() {
  388. return get_option( 'catchbox_theme_options', catchbox_get_default_theme_options() );
  389. }
  390. /**
  391. * Renders the Color Scheme setting field.
  392. *
  393. * @since Catch Box 1.0
  394. */
  395. function catchbox_settings_field_color_scheme() {
  396. $options = catchbox_get_theme_options();
  397. foreach ( catchbox_color_schemes() as $scheme ) {
  398. ?>
  399. <div class="layout image-radio-option color-scheme">
  400. <label class="description">
  401. <input type="radio" name="catchbox_theme_options[color_scheme]" value="<?php echo esc_attr( $scheme['value'] ); ?>" <?php checked( $options['color_scheme'], $scheme['value'] ); ?> />
  402. <input type="hidden" id="default-color-<?php echo esc_attr( $scheme['value'] ); ?>" value="<?php echo esc_attr( $scheme['default_link_color'] ); ?>" />
  403. <span>
  404. <img src="<?php echo esc_url( $scheme['thumbnail'] ); ?>" width="164" height="122" alt="" />
  405. <?php echo $scheme['label']; ?>
  406. </span>
  407. </label>
  408. </div>
  409. <?php
  410. }
  411. }
  412. /**
  413. * Renders the Link Color setting field.
  414. *
  415. * @since Catch Box 1.0
  416. */
  417. function catchbox_settings_field_link_color() {
  418. $options = catchbox_get_theme_options();
  419. ?>
  420. <input type="text" name="catchbox_theme_options[link_color]" id="link-color" value="<?php echo esc_attr( $options['link_color'] ); ?>" />
  421. <a href="#" class="pickcolor hide-if-no-js" id="link-color-example"></a>
  422. <input type="button" class="pickcolor button hide-if-no-js" value="<?php esc_attr_e( 'Select a Color', 'catchbox' ); ?>" />
  423. <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div>
  424. <br />
  425. <span><?php printf( __( 'Default color: %s', 'catchbox' ), '<span id="default-color">' . catchbox_get_default_link_color( $options['color_scheme'] ) . '</span>' ); ?></span>
  426. <?php
  427. }
  428. /**
  429. * Renders the excerpt length setting field.
  430. *
  431. * @since Catch Box 1.1.3
  432. */
  433. function catchbox_settings_field_excerpt_length() {
  434. $options = catchbox_get_theme_options();
  435. if( empty( $options['excerpt_length'] ) )
  436. $options = catchbox_get_default_theme_options();
  437. ?>
  438. <input type="text" name="catchbox_theme_options[excerpt_length]" id="excerpt-length" size="3" value="<?php if ( isset( $options[ 'excerpt_length' ] ) ) echo absint( $options[ 'excerpt_length'] ); ?>" />
  439. <?php
  440. }
  441. /**
  442. * Renders the feed redirect setting field.
  443. *
  444. * @since Catch Box 1.0
  445. */
  446. function catchbox_settings_field_feed_redirect() {
  447. $options = catchbox_get_theme_options();
  448. ?>
  449. <input type="text" name="catchbox_theme_options[feed_url]" id="feed-url" size="65" value="<?php if ( isset( $options[ 'feed_url' ] ) ) echo esc_attr( $options[ 'feed_url'] ); ?>" />
  450. <?php
  451. }
  452. /**
  453. * Renders the feed redirect setting field.
  454. *
  455. * @since Catch Box 1.3.1
  456. */
  457. function catchbox_settings_field_disable_header_search() {
  458. $options = catchbox_get_theme_options();
  459. if( empty( $options['disable_header_search'] ) )
  460. $options = catchbox_get_default_theme_options();
  461. ?>
  462. <input type="checkbox" id="disable-header-search" name="catchbox_theme_options[disable_header_search]" value="1" <?php checked( '1', $options['disable_header_search'] ); ?> />
  463. <?php
  464. }
  465. /**
  466. * Renders the Custom CSS styles setting fields
  467. *
  468. * @since Catch Box 1.0
  469. */
  470. function catchbox_settings_field_custom_css() {
  471. $options = catchbox_get_theme_options();
  472. ?>
  473. <textarea id="custom-css" cols="90" rows="12" name="catchbox_theme_options[custom_css]"><?php if (!empty($options['custom_css'] ) )echo esc_attr($options['custom_css']); ?></textarea> <br />
  474. <?php _e('CSS Tutorial from W3Schools.', 'catchbox'); ?> <a class="button" href="<?php echo esc_url( __( 'http://www.w3schools.com/css/default.asp','catchbox' ) ); ?>" title="<?php esc_attr_e( 'CSS Tutorial', 'catchbox' ); ?>" target="_blank"><?php _e( 'Click Here to Read', 'catchbox' );?></a>
  475. <?php
  476. }
  477. /**
  478. * Renders the Layout setting field.
  479. *
  480. * @since Catch Box 1.0
  481. */
  482. function catchbox_settings_field_layout() {
  483. $options = catchbox_get_theme_options();
  484. foreach ( catchbox_layouts() as $layout ) {
  485. ?>
  486. <div class="layout image-radio-option theme-layout">
  487. <label class="description">
  488. <input type="radio" name="catchbox_theme_options[theme_layout]" value="<?php echo esc_attr( $layout['value'] ); ?>" <?php checked( $options['theme_layout'], $layout['value'] ); ?> />
  489. <span>
  490. <img src="<?php echo esc_url( $layout['thumbnail'] ); ?>" width="136" height="122" alt="" />
  491. <?php echo $layout['label']; ?>
  492. </span>
  493. </label>
  494. </div>
  495. <?php
  496. }
  497. }
  498. /**
  499. * Renders the Content layout setting fields.
  500. *
  501. * @since Catch Box 1.0
  502. */
  503. function catchbox_settings_field_content_scheme() {
  504. $options = catchbox_get_theme_options();
  505. foreach ( catchbox_content_layout() as $content ) {
  506. ?>
  507. <div class="layout image-radio-option theme-layout">
  508. <label class="description">
  509. <input type="radio" name="catchbox_theme_options[content_layout]" value="<?php echo esc_attr( $content['value'] ); ?>" <?php checked( $options['content_layout'], $content['value'] ); ?> />
  510. <span>
  511. <img src="<?php echo esc_url( $content['thumbnail'] ); ?>" width="164" height="163" alt="" />
  512. <?php echo $content['label']; ?>
  513. </span>
  514. </label>
  515. </div>
  516. <?php
  517. }
  518. }
  519. /**
  520. * Returns the options array for Catch Box.
  521. *
  522. * @since Catch Box 1.0
  523. */
  524. function catchbox_theme_options_render_page() {
  525. ?>
  526. <div class="wrap">
  527. <?php screen_icon(); ?>
  528. <h2>
  529. <?php
  530. if( function_exists( 'wp_get_theme' ) ) {
  531. printf( __( '%s Theme Options By', 'catchbox' ), wp_get_theme() );
  532. } else {
  533. printf( __( '%s Theme Options By', 'catchbox' ), get_current_theme() );
  534. }
  535. ?>
  536. <a href="<?php echo esc_url( __( 'http://catchthemes.com/', 'catchbox' ) ); ?>" title="<?php echo esc_attr_e( 'Catch Themes', 'catchbox' ); ?>" target="_blank"><?php _e( 'Catch Themes', 'catchbox' ); ?></a>
  537. </h2>
  538. <div id="info-support">
  539. <a class="support button" href="<?php echo esc_url(__('http://catchthemes.com/support/','catchbox')); ?>" title="<?php esc_attr_e('Theme Support', 'catchbox'); ?>" target="_blank">
  540. <?php printf(__('Theme Support','catchbox')); ?></a>
  541. <a class="themes button" href="<?php echo esc_url(__('http://catchthemes.com/themes/catch-box-pro/','catchbox')); ?>" title="<?php esc_attr_e('Upgrade to Catch Box Pro', 'catchbox'); ?>" target="_blank">
  542. <?php printf(__('Upgrade to Catch Box Pro','catchbox')); ?></a>
  543. <a class="facebook button" href="<?php echo esc_url(__('http://facebook.com/catchthemes','catchbox')); ?>" title="<?php esc_attr_e('Facebook', 'catchbox'); ?>" target="_blank">
  544. <?php printf(__('Facebook','catchbox')); ?></a>
  545. <a class="twitter button" href="<?php echo esc_url(__('http://twitter.com/#!/catchthemes','catchbox')); ?>" title="<?php esc_attr_e('Twitter', 'catchbox'); ?>" target="_blank">
  546. <?php printf(__('Twitter','catchbox')); ?></a>
  547. <a class="donate button" href="<?php echo esc_url(__('http://catchthemes.com/donate/','catchbox')); ?>" title="<?php esc_attr_e('Donate Now', 'catchbox'); ?>" target="_blank">
  548. <?php printf(__('Donate Now','catchbox')); ?></a>
  549. </div>
  550. <?php settings_errors(); ?>
  551. <form method="post" action="options.php">
  552. <?php
  553. settings_fields( 'catchbox_options' );
  554. do_settings_sections( 'theme_options' );
  555. submit_button();
  556. ?>
  557. </form>
  558. </div>
  559. <?php
  560. }
  561. /**
  562. * Renders the slider options for Catch Box.
  563. *
  564. * @since Catch Box 1.0
  565. */
  566. function catchbox_options_slider_page() {
  567. ?>
  568. <div class="wrap">
  569. <?php screen_icon(); ?>
  570. <h2>
  571. <?php
  572. if( function_exists( 'wp_get_theme' ) ) {
  573. printf( __( '%s Theme Options By', 'catchbox' ), wp_get_theme() );
  574. } else {
  575. printf( __( '%s Theme Options By', 'catchbox' ), get_current_theme() );
  576. }
  577. ?>
  578. <a href="<?php echo esc_url( __( 'http://catchthemes.com/', 'catchbox' ) ); ?>" title="<?php echo esc_attr_e( 'Catch Themes', 'catchbox' ); ?>" target="_blank"><?php _e( 'Catch Themes', 'catchbox' ); ?></a></h2>
  579. <form method="post" action="options.php">
  580. <?php
  581. settings_fields( 'catchbox_options_slider' );
  582. $options = get_option( 'catchbox_options_slider' );
  583. if( is_array( $options ) && ( !array_key_exists( 'slider_qty', $options ) || !is_numeric( $options[ 'slider_qty' ] ) ) ) $options[ 'slider_qty' ] = 4;
  584. elseif( !is_array( $options ) ) $options = array( 'slider_qty' => 4);
  585. ?>
  586. <?php if( isset( $_GET [ 'settings-updated' ] ) && $_GET[ 'settings-updated' ] == 'true' ): ?>
  587. <div class="updated" id="message">
  588. <p><strong><?php _e( 'Settings saved.', 'catchbox' );?></strong></p>
  589. </div>
  590. <?php endif; ?>
  591. <div class="option-container">
  592. <h3 class="option-toggle"><a href="#"><?php _e( 'Slider Options', 'catchbox' ); ?></a></h3>
  593. <div class="option-content inside">
  594. <table class="form-table">
  595. <tr>
  596. <th scope="row"><?php _e( 'Exclude Slider post from Home page posts:', 'catchbox' ); ?></th>
  597. <input type='hidden' value='0' name='catchbox_options_slider[exclude_slider_post]'>
  598. <td><input type="checkbox" id="headerlogo" name="catchbox_options_slider[exclude_slider_post]" value="1" <?php isset($options['exclude_slider_post']) ? checked( '1', $options['exclude_slider_post'] ) : checked('0', '1'); ?> /> <?php _e( 'Check to disable', 'catchbox' ); ?></td>
  599. </tr>
  600. <tr>
  601. <th scope="row"><?php _e( 'Number of Slides', 'catchbox' ); ?></th>
  602. <td><input type="text" name="catchbox_options_slider[slider_qty]" value="<?php if ( array_key_exists ( 'slider_qty', $options ) ) echo intval( $options[ 'slider_qty' ] ); ?>" /></td>
  603. </tr>
  604. <tbody class="sortable">
  605. <?php for ( $i = 1; $i <= $options[ 'slider_qty' ]; $i++ ): ?>
  606. <tr>
  607. <th scope="row"><label class="handle"><?php _e( 'Featured Col #', 'catchbox' ); ?><span class="count"><?php echo absint( $i ); ?></span></label></th>
  608. <td><input type="text" name="catchbox_options_slider[featured_slider][<?php echo absint( $i ); ?>]" value="<?php if( array_key_exists( 'featured_slider', $options ) && array_key_exists( $i, $options[ 'featured_slider' ] ) ) echo absint( $options[ 'featured_slider' ][ $i ] ); ?>" />
  609. <a href="<?php bloginfo ( 'url' );?>/wp-admin/post.php?post=<?php if( array_key_exists ( 'featured_slider', $options ) && array_key_exists ( $i, $options[ 'featured_slider' ] ) ) echo absint( $options[ 'featured_slider' ][ $i ] ); ?>&action=edit" class="button" title="<?php esc_attr_e('Click Here To Edit'); ?>" target="_blank"><?php _e( 'Click Here To Edit', 'catchbox' ); ?></a>
  610. </td>
  611. </tr>
  612. <?php endfor; ?>
  613. </tbody>
  614. </table>
  615. <p><?php _e( '<strong>Note</strong>: Here you add in Post IDs which displays on Homepage Featured Slider.', 'catchbox' ); ?> </p>
  616. <p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save', 'catchbox' ); ?>" /></p>
  617. </div><!-- .option-content -->
  618. </div><!-- .option-container -->
  619. <div class="option-container">
  620. <h3 class="option-toggle"><a href="#"><?php _e( 'Slider Effect Options', 'catchbox' ); ?></a></h3>
  621. <div class="option-content inside">
  622. <table class="form-table">
  623. <tr>
  624. <th>
  625. <label for="catchbox_cycle_style"><?php _e( 'Transition Effect:', 'catchbox' ); ?></label>
  626. </th>
  627. <?php if( empty( $options['transition_effect'] ) ) { $options['transition_effect'] = "fade"; } ?>
  628. <td>
  629. <select id="catchbox_cycle_style" name="catchbox_options_slider[transition_effect]">
  630. <option value="fade" <?php selected('fade', $options['transition_effect']); ?>><?php _e( 'fade', 'catchbox' ); ?></option>
  631. <option value="wipe" <?php selected('wipe', $options['transition_effect']); ?>><?php _e( 'wipe', 'catchbox' ); ?></option>
  632. <option value="scrollUp" <?php selected('scrollUp', $options['transition_effect']); ?>><?php _e( 'scrollUp', 'catchbox' ); ?></option>
  633. <option value="scrollDown" <?php selected('scrollDown', $options['transition_effect']); ?>><?php _e( 'scrollDown', 'catchbox' ); ?></option>
  634. <option value="scrollLeft" <?php selected('scrollLeft', $options['transition_effect']); ?>><?php _e( 'scrollLeft', 'catchbox' ); ?></option>
  635. <option value="scrollRight" <?php selected('scrollRight', $options['transition_effect']); ?>><?php _e( 'scrollRight', 'catchbox' ); ?></option>
  636. <option value="blindX" <?php selected('blindX', $options['transition_effect']); ?>><?php _e( 'blindX', 'catchbox' ); ?></option>
  637. <option value="blindY" <?php selected('blindY', $options['transition_effect']); ?>><?php _e( 'blindY', 'catchbox' ); ?></option>
  638. <option value="blindZ" <?php selected('blindZ', $options['transition_effect']); ?>><?php _e( 'blindZ', 'catchbox' ); ?></option>
  639. <option value="cover" <?php selected('cover', $options['transition_effect']); ?>><?php _e( 'cover', 'catchbox' ); ?></option>
  640. <option value="shuffle" <?php selected('shuffle', $options['transition_effect']); ?>><?php _e( 'shuffle', 'catchbox' ); ?></option>
  641. </select>
  642. </td>
  643. </tr>
  644. <?php if( empty( $options['transition_delay'] ) ) { $options['transition_delay'] = 4; } ?>
  645. <tr>
  646. <th scope="row"><?php _e( 'Transition Delay', 'catchbox' ); ?></th>
  647. <td>
  648. <input type="text" name="catchbox_options_slider[transition_delay]" value="<?php if( isset( $options [ 'transition_delay' ] ) ) echo $options[ 'transition_delay' ]; ?>" size="4" />
  649. <span class="description"><?php _e( 'second(s)', 'catchbox' ); ?></span>
  650. </td>
  651. </tr>
  652. <?php if( empty( $options['transition_duration'] ) ) { $options['transition_duration'] = 1; } ?>
  653. <tr>
  654. <th scope="row"><?php _e( 'Transition Length', 'catchbox' ); ?></th>
  655. <td>
  656. <input type="text" name="catchbox_options_slider[transition_duration]" value="<?php if( isset( $options [ 'transition_duration' ] ) ) echo $options[ 'transition_duration' ]; ?>" size="4" />
  657. <span class="description"><?php _e( 'second(s)', 'catchbox' ); ?></span>
  658. </td>
  659. </tr>
  660. </table>
  661. <p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save', 'catchbox' ); ?>" /></p>
  662. </div><!-- .option-content -->
  663. </div><!-- .option-container -->
  664. </form>
  665. </div><!-- .wrap -->
  666. <?php
  667. }
  668. /**
  669. * Renders the social links options for Catch Box.
  670. *
  671. * @since Catch Box 1.0
  672. */
  673. function catchbox_options_social_links() {
  674. ?>
  675. <div class="wrap">
  676. <?php screen_icon(); ?>
  677. <h2>
  678. <?php
  679. if( function_exists( 'wp_get_theme' ) ) {
  680. printf( __( '%s Theme Options By', 'catchbox' ), wp_get_theme() );
  681. } else {
  682. printf( __( '%s Theme Options By', 'catchbox' ), get_current_theme() );
  683. }
  684. ?> <a href="<?php echo esc_url( __( 'http://catchthemes.com/', 'catchbox' ) ); ?>" title="<?php echo esc_attr_e( 'Catch Themes', 'catchbox' ); ?>" target="_blank"><?php _e( 'Catch Themes', 'catchbox' ); ?></a></h2>
  685. <form method="post" action="options.php">
  686. <?php
  687. settings_fields( 'catchbox_options_social_links' );
  688. $options = get_option( 'catchbox_options_social_links' );
  689. ?>
  690. <?php if( isset( $_GET [ 'settings-updated' ] ) && $_GET[ 'settings-updated' ] == 'true' ): ?>
  691. <div class="updated" id="message">
  692. <p><strong><?php _e( 'Settings saved.', 'catchbox' );?></strong></p>
  693. </div>
  694. <?php endif; ?>
  695. <table class="form-table">
  696. <tbody>
  697. <tr>
  698. <th scope="row"><label><?php _e( 'Facebook', 'catchbox' ); ?></label></th>
  699. <td><input type="text" size="45" name="catchbox_options_social_links[social_facebook]" value="<?php if( isset( $options[ 'social_facebook' ] ) ) echo esc_url( $options[ 'social_facebook' ] ); ?>" />
  700. </td>
  701. </tr>
  702. <tr>
  703. <th scope="row"><label><?php _e( 'Twitter', 'catchbox' ); ?></label></th>
  704. <td><input type="text" size="45" name="catchbox_options_social_links[social_twitter]" value="<?php if ( isset( $options[ 'social_twitter' ] ) ) echo esc_url( $options[ 'social_twitter'] ); ?>" />
  705. </td>
  706. </tr>
  707. <tr>
  708. <th scope="row"><label><?php _e( 'Google +', 'catchbox' ); ?></label></th>
  709. <td><input type="text" size="45" name="catchbox_options_social_links[social_google]" value="<?php if ( isset( $options[ 'social_google' ] ) ) echo esc_url( $options[ 'social_google' ] ); ?>" />
  710. </td>
  711. </tr>
  712. <tr>
  713. <th scope="row"><label><?php _e( 'LinkedIn', 'catchbox' ); ?></label></th>
  714. <td><input type="text" size="45" name="catchbox_options_social_links[social_linkedin]" value="<?php if ( isset( $options[ 'social_linkedin' ] ) ) echo esc_url( $options[ 'social_linkedin' ] ); ?>" />
  715. </td>
  716. </tr>
  717. <tr>
  718. <th scope="row"><label><?php _e( 'Pinterest', 'catchbox' ); ?></label></th>
  719. <td><input type="text" size="45" name="catchbox_options_social_links[social_pinterest]" value="<?php if ( isset( $options[ 'social_pinterest' ] ) ) echo esc_url( $options[ 'social_pinterest' ] ); ?>" />
  720. </td>
  721. </tr>
  722. <tr>
  723. <th scope="row"><label><?php _e( 'Youtube', 'catchbox' ); ?></label></th>
  724. <td><input type="text" size="45" name="catchbox_options_social_links[social_youtube]" value="<?php if ( isset( $options[ 'social_youtube' ] ) ) echo esc_url( $options[ 'social_youtube' ] ); ?>" />
  725. </td>
  726. </tr>
  727. <tr>
  728. <th scope="row"><label><?php _e( 'RSS Feed', 'catchbox' ); ?></label></th>
  729. <td><input type="text" size="45" name="catchbox_options_social_links[social_rss]" value="<?php if ( isset( $options[ 'social_rss' ] ) ) echo esc_url( $options[ 'social_rss' ] ); ?>" />
  730. </td>
  731. </tr>
  732. <tr>
  733. <th scope="row"><label><?php _e( 'Deviantart', 'catchbox' ); ?></label></th>
  734. <td><input type="text" size="45" name="catchbox_options_social_links[social_deviantart]" value="<?php if ( isset( $options[ 'social_deviantart' ] ) ) echo esc_url( $options[ 'social_deviantart' ] ); ?>" />
  735. </td>
  736. </tr>
  737. <tr>
  738. <th scope="row"><label><?php _e( 'Tumblr', 'catchbox' ); ?></label></th>
  739. <td><input type="text" size="45" name="catchbox_options_social_links[social_tumblr]" value="<?php if ( isset( $options[ 'social_tumblr' ] ) ) echo esc_url( $options[ 'social_tumblr' ] ); ?>" />
  740. </td>
  741. </tr>
  742. <tr>
  743. <th scope="row"><label><?php _e( 'Vimeo', 'catchbox' ); ?></label></th>
  744. <td><input type="text" size="45" name="catchbox_options_social_links[social_viemo]" value="<?php if ( isset( $options[ 'social_viemo' ] ) ) echo esc_url( $options[ 'social_viemo' ] ); ?>" />
  745. </td>
  746. </tr>
  747. <tr>
  748. <th scope="row"><label><?php _e( 'Dribbble', 'catchbox' ); ?></label></th>
  749. <td><input type="text" size="45" name="catchbox_options_social_links[social_dribbble]" value="<?php if ( isset( $options[ 'social_dribbble' ] ) ) echo esc_url( $options[ 'social_dribbble' ] ); ?>" />
  750. </td>
  751. </tr>
  752. <tr>
  753. <th scope="row"><label><?php _e( 'MySpace', 'catchbox' ); ?></label></th>
  754. <td><input type="text" size="45" name="catchbox_options_social_links[social_myspace]" value="<?php if ( isset( $options[ 'social_myspace' ] ) ) echo esc_url( $options[ 'social_myspace' ] ); ?>" />
  755. </td>
  756. </tr>
  757. <tr>
  758. <th scope="row"><label><?php _e( 'Aim', 'catchbox' ); ?></label></th>
  759. <td><input type="text" size="45" name="catchbox_options_social_links[social_aim]" value="<?php if ( isset( $options[ 'social_aim' ] ) ) echo esc_url( $options[ 'social_aim' ] ); ?>" />
  760. </td>
  761. </tr>
  762. <tr>
  763. <th scope="row"><label><?php _e( 'Flickr', 'catchbox' ); ?></label></th>
  764. <td><input type="text" size="45" name="catchbox_options_social_links[social_flickr]" value="<?php if ( isset( $options[ 'social_flickr' ] ) ) echo esc_url( $options[ 'social_flickr' ] ); ?>" />
  765. </td>
  766. </tr>
  767. </tbody>
  768. </table>
  769. <p><?php _e( '<strong>Note:</strong> Enter the url for correponding social networking website', 'catchbox' ); ?></p>
  770. <p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save', 'catchbox' ); ?>" /></p>
  771. </form>
  772. </div><!-- .wrap -->
  773. <?php
  774. }
  775. /**
  776. * Returns the options array for Catch Box.
  777. *
  778. * @since Catch Box 1.0
  779. */
  780. function catchbox_options_webmaster_tools() {
  781. ?>
  782. <div class="wrap">
  783. <?php screen_icon(); ?>
  784. <h2>
  785. <?php
  786. if( function_exists( 'wp_get_theme' ) ) {
  787. printf( __( '%s Theme Options By', 'catchbox' ), wp_get_theme() );
  788. } else {
  789. printf( __( '%s Theme Options By', 'catchbox' ), get_current_theme() );
  790. }
  791. ?>
  792. <a href="<?php echo esc_url( __( 'http://catchthemes.com/', 'catchbox' ) ); ?>" title="<?php echo esc_attr_e( 'Catch Themes', 'catchbox' ); ?>" target="_blank"><?php _e( 'Catch Themes', 'catchbox' ); ?></a></h2>
  793. <form method="post" action="options.php">
  794. <?php
  795. settings_fields( 'catchbox_options_webmaster' );
  796. $options = get_option( 'catchbox_options_webmaster' );
  797. ?>
  798. <?php if( isset( $_GET [ 'settings-updated' ] ) && $_GET[ 'settings-updated' ] == 'true' ): ?>
  799. <div class="updated" id="message">
  800. <p><strong><?php _e( 'Settings saved.', 'catchbox' );?></strong></p>
  801. </div>
  802. <?php endif; ?>
  803. <div class="option-container">
  804. <h3 class="option-toggle"><a href="#"><?php _e( 'Webmaster Site Verification IDs', 'catchbox' ); ?></a></h3>
  805. <div class="option-content inside">
  806. <table class="form-table">
  807. <tbody>
  808. <tr>
  809. <th scope="row"><label><?php _e( 'Google Site Verification ID', 'catchbox' ); ?></label></th>
  810. <td><input type="text" size="45" name="catchbox_options_webmaster[google_verification]" value="<?php if( isset( $options[ 'google_verification' ] ) ) echo esc_attr( $options[ 'google_verification' ] ); ?>" /> <?php _e('Enter your Google ID number only', 'catchbox'); ?>
  811. </td>
  812. </tr>
  813. <tr>
  814. <th scope="row"><label><?php _e( 'Yahoo Site Verification ID', 'catchbox' ); ?> </label></th>
  815. <td><input type="text" size="45" name="catchbox_options_webmaster[yahoo_verification]" value="<?php if ( isset( $options[ 'yahoo_verification' ] ) ) echo esc_attr( $options[ 'yahoo_verification'] ); ?>" /> <?php _e('Enter your Yahoo ID number only', 'catchbox'); ?>
  816. </td>
  817. </tr>
  818. <tr>
  819. <th scope="row"><label><?php _e( 'Bing Site Verification ID', 'catchbox' ); ?></label></th>
  820. <td><input type="text" size="45" name="catchbox_options_webmaster[bing_verification]" value="<?php if ( isset( $options[ 'bing_verification' ] ) ) echo esc_attr( $options[ 'bing_verification' ] ); ?>" /> <?php _e('Enter your Bing ID number only', 'catchbox'); ?>
  821. </td>
  822. </tr>
  823. </tbody>
  824. </table>
  825. <p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save', 'catchbox' ); ?>" /></p>
  826. </div> <!-- .option-content -->
  827. </div> <!-- .option-container -->
  828. <div class="option-container">
  829. <h3 class="option-toggle"><a href="#"><?php _e( 'Webmaster Site Verification Code', 'catchbox' ); ?></a></h3>
  830. <div class="option-content inside">
  831. <table class="form-table">
  832. <table class="form-table">
  833. <tr>
  834. <th scope="row"><label><?php _e('Analytics, site stats Header code', 'catchbox' ); ?></label></th>
  835. <td>
  836. <textarea name="catchbox_options_webmaster[tracker_header]" rows="7" cols="80" ><?php if ( isset( $options [ 'tracker_header' ] ) ) echo esc_attr( $options[ 'tracker_header' ] ); ?></textarea>
  837. </td>
  838. </tr>
  839. <tr>
  840. <th scope="row"><label><?php _e('Analytics, site stats footer code', 'catchbox' ); ?></label></th>
  841. <td>
  842. <textarea name="catchbox_options_webmaster[tracker_footer]" rows="7" cols="80" ><?php if ( isset( $options [ 'tracker_footer' ] ) ) echo esc_attr( $options[ 'tracker_footer' ] ); ?></textarea>
  843. </td>
  844. </tr>
  845. </tbody>
  846. </table>
  847. <p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save', 'catchbox' ); ?>" /></p>
  848. </div> <!-- .option-content -->
  849. </div> <!-- .option-container -->
  850. </form>
  851. </div><!-- .wrap -->
  852. <?php
  853. }
  854. /**
  855. * Sanitize and validate form input. Accepts an array, return a sanitized array.
  856. *
  857. * @since Catch Box 1.0
  858. */
  859. function catchbox_options_validation($options) {
  860. $options_validated = array();
  861. //data validation for Featured Slider
  862. if ( isset( $options[ 'slider_qty' ] ) ) {
  863. $options_validated[ 'slider_qty' ] = absint( $options[ 'slider_qty' ] ) ? $options [ 'slider_qty' ] : 4;
  864. }
  865. if ( isset( $options[ 'featured_slider' ] ) ) {
  866. $options_validated[ 'featured_slider' ] = array();
  867. }
  868. if( isset( $options[ 'slider_qty' ] ) )
  869. for ( $i = 1; $i <= $options [ 'slider_qty' ]; $i++ ) {
  870. if ( absint( $options[ 'featured_slider' ][ $i ] ) )
  871. $options_validated[ 'featured_slider' ][ $i ] = absint($options[ 'featured_slider' ][ $i ] );
  872. }
  873. if ( isset( $options['exclude_slider_post'] ) ) {
  874. // Our checkbox value is either 0 or 1
  875. $options_validated[ 'exclude_slider_post' ] = $options[ 'exclude_slider_post' ];
  876. }
  877. if( !empty( $options[ 'transition_effect' ] ) ) {
  878. $options_validated['transition_effect'] = wp_filter_nohtml_kses( $options['transition_effect'] );
  879. }
  880. // data validation for transition delay
  881. if ( !empty( $options[ 'transition_delay' ] ) && is_numeric( $options[ 'transition_delay' ] ) ) {
  882. $options_validated[ 'transition_delay' ] = $options[ 'transition_delay' ];
  883. }
  884. // data validation for transition length
  885. if ( !empty( $options[ 'transition_duration' ] ) && is_numeric( $options[ 'transition_duration' ] ) ) {
  886. $options_validated[ 'transition_duration' ] = $options[ 'transition_duration' ];
  887. }
  888. //Clearing the theme option cache
  889. if( function_exists( 'catchbox_themeoption_invalidate_caches' ) ) { catchbox_themeoption_invalidate_caches(); }
  890. return $options_validated;
  891. }
  892. /**
  893. * Sanitize and validate forms for webmaster tools options. Accepts an array, return a sanitized array.
  894. *
  895. * @since Catch Box 1.0
  896. */
  897. function catchbox_options_webmaster_validation( $options ) {
  898. $options_validated = array();
  899. // data validation for verification id
  900. if( isset( $options[ 'google_verification' ] ) ) {
  901. $options_validated[ 'google_verification' ] = wp_filter_post_kses( $options[ 'google_verification' ] );
  902. }
  903. if( isset( $options[ 'yahoo_verification' ] ) )
  904. $options_validated[ 'yahoo_verification' ] = wp_filter_post_kses( $options[ 'yahoo_verification' ] );
  905. if( isset( $options[ 'bing_verification' ] ) )
  906. $options_validated[ 'bing_verification' ] = wp_filter_post_kses( $options[ 'bing_verification' ] );
  907. // data validation for tracking code
  908. if( isset( $options[ 'tracker_header' ] ) )
  909. $options_validated[ 'tracker_header' ] = wp_kses_stripslashes( $options[ 'tracker_header' ] );
  910. if( isset( $options[ 'tracker_footer' ] ) )
  911. $options_validated[ 'tracker_footer' ] = wp_kses_stripslashes( $options[ 'tracker_footer' ] );
  912. return $options_validated;
  913. }
  914. /**
  915. * Sanitize and validate social links options form. Accepts an array, return a sanitized array.
  916. *
  917. * @since Catch Box 1.0
  918. */
  919. function catchbox_options_social_links_validation( $options ) {
  920. $options_validated = array();
  921. // data validation for Sociallinks
  922. //Facebook
  923. if( isset( $options[ 'social_facebook' ] ) )
  924. $options_validated[ 'social_facebook' ] = esc_url_raw( $options[ 'social_facebook' ] );
  925. //Twitter
  926. if( isset( $options[ 'social_twitter' ] ) )
  927. $options_validated[ 'social_twitter' ] = esc_url_raw( $options[ 'social_twitter' ] );
  928. //Youtube
  929. if( isset( $options[ 'social_youtube' ] ) )
  930. $options_validated[ 'social_youtube' ] = esc_url_raw( $options[ 'social_youtube' ] );
  931. //Google+
  932. if( isset( $options[ 'social_google' ] ) )
  933. $options_validated[ 'social_google' ] = esc_url_raw( $options[ 'social_google' ] );
  934. //RSS
  935. if( isset( $options[ 'social_rss' ] ) )
  936. $options_validated[ 'social_rss' ] = esc_url_raw( $options[ 'social_rss' ] );
  937. //Linkedin
  938. if( isset( $options[ 'social_linkedin' ] ) )
  939. $options_validated[ 'social_linkedin' ] = esc_url_raw( $options[ 'social_linkedin' ] );
  940. //Pinterest
  941. if( isset( $options[ 'social_pinterest' ] ) )
  942. $options_validated[ 'social_pinterest' ] = esc_url_raw( $options[ 'social_pinterest' ] );
  943. //Deviantart
  944. if( isset( $options[ 'social_deviantart' ] ) )
  945. $options_validated[ 'social_deviantart' ] = esc_url_raw( $options[ 'social_deviantart' ] );
  946. //Tumblr
  947. if( isset( $options[ 'social_tumblr' ] ) )
  948. $options_validated[ 'social_tumblr' ] = esc_url_raw( $options[ 'social_tumblr' ] );
  949. //Viemo
  950. if( isset( $options[ 'social_viemo' ] ) )
  951. $options_validated[ 'social_viemo' ] = esc_url_raw( $options[ 'social_viemo' ] );
  952. //Dribble
  953. if( isset( $options[ 'social_dribbble' ] ) )
  954. $options_validated[ 'social_dribbble' ] = esc_url_raw( $options[ 'social_dribbble' ] );
  955. //Myspace
  956. if( isset( $options[ 'social_myspace' ] ) )
  957. $options_validated[ 'social_myspace' ] = esc_url_raw( $options[ 'social_myspace' ] );
  958. //Aim
  959. if( isset( $options[ 'social_aim' ] ) )
  960. $options_validated[ 'social_aim' ] = esc_url_raw( $options[ 'social_aim' ] );
  961. //Flickr
  962. if( isset( $options[ 'social_flickr' ] ) )
  963. $options_validated[ 'social_flickr' ] = esc_url_raw( $options[ 'social_flickr' ] );
  964. //Clearing the theme option cache
  965. if( function_exists( 'catchbox_themeoption_invalidate_caches' ) ) { catchbox_themeoption_invalidate_caches(); }
  966. return $options_validated;
  967. }
  968. /**
  969. * Sanitize and validate form input. Accepts an array, return a sanitized array.
  970. *
  971. * @see catchbox_theme_options_init()
  972. * @todo set up Reset Options action
  973. *
  974. * @since Catch Box 1.0
  975. */
  976. function catchbox_theme_options_validate( $input ) {
  977. $output = $defaults = catchbox_get_default_theme_options();
  978. // favicon url
  979. if ( isset( $input['fav_icon'] ) )
  980. $output['fav_icon'] = esc_url_raw($input['fav_icon']);
  981. // web clicp icon url
  982. if ( isset( $input['web_clip'] ) )
  983. $output['web_clip'] = esc_url_raw($input['web_clip']);
  984. // Color scheme must be in our array of color scheme options
  985. if ( isset( $input['color_scheme'] ) && array_key_exists( $input['color_scheme'], catchbox_color_schemes() ) )
  986. $output['color_scheme'] = $input['color_scheme'];
  987. // Our defaults for the link color may have changed, based on the color scheme.
  988. $output['link_color'] = $defaults['link_color'] = catchbox_get_default_link_color( $output['color_scheme'] );
  989. // Link color must be 3 or 6 hexadecimal characters
  990. if ( isset( $input['link_color'] ) && preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'] ) )
  991. $output['link_color'] = '#' . strtolower( ltrim( $input['link_color'], '#' ) );
  992. // Theme layout must be in our array of theme layout options
  993. if ( isset( $input['theme_layout'] ) && array_key_exists( $input['theme_layout'], catchbox_layouts() ) )
  994. $output['theme_layout'] = $input['theme_layout'];
  995. // Theme layout must be in our array of theme layout options
  996. if ( isset( $input['content_layout'] ) && array_key_exists( $input['content_layout'], catchbox_content_layout() ) )
  997. $output['content_layout'] = $input['content_layout'];
  998. // excerpt length
  999. if ( isset( $input['excerpt_length'] ) )
  1000. $output['excerpt_length'] = absint($input['excerpt_length']);
  1001. // feed url
  1002. if ( isset( $input['feed_url'] ) )
  1003. $output['feed_url'] = esc_url_raw($input['feed_url']);
  1004. // Disable Header Search
  1005. if ( isset( $input['disable_header_search'] ) )
  1006. // Our checkbox value is either 0 or 1
  1007. $output[ 'disable_header_search' ] = $input[ 'disable_header_search' ];
  1008. // Custom CSS
  1009. if ( isset( $input['custom_css'] ) )
  1010. $output['custom_css'] = wp_kses_stripslashes($input['custom_css']);
  1011. if( function_exists( 'catchbox_themeoption_invalidate_caches' ) ) { catchbox_themeoption_invalidate_caches(); }
  1012. return apply_filters( 'catchbox_theme_options_validate', $output, $input, $defaults );
  1013. }
  1014. /**
  1015. * Get the favicon Image from theme options
  1016. *
  1017. * @uses favicon
  1018. * @get the data value of image from theme options
  1019. * @display favicon
  1020. *
  1021. * @uses set_transient and delete_transient
  1022. */
  1023. function catchbox_favicon() {
  1024. //delete_transient( 'catchbox_favicon' );
  1025. if ( !$catchbox_favicon = get_transient( 'catchbox_favicon' ) ) {
  1026. $options = catchbox_get_theme_options();
  1027. if ( !empty( $options['fav_icon'] ) ) {
  1028. $catchbox_favicon = '<link rel="shortcut icon" href="'.esc_url( $options[ 'fav_icon' ] ).'" type="image/x-icon" />';
  1029. }
  1030. set_transient( 'catchbox_favicon', $catchbox_favicon, 86940 );
  1031. }
  1032. echo $catchbox_favicon ;
  1033. }
  1034. //Load Favicon in Header Section
  1035. add_action('wp_head', 'catchbox_favicon');
  1036. //Load Favicon in Admin Section
  1037. add_action( 'admin_head', 'catchbox_favicon' );
  1038. /**
  1039. * Enqueue the styles for the current color scheme.
  1040. *
  1041. * @since Catch Box 1.0
  1042. */
  1043. function catchbox_enqueue_color_scheme() {
  1044. $options = catchbox_get_theme_options();
  1045. $color_scheme = $options['color_scheme'];
  1046. if ( 'dark' == $color_scheme )
  1047. wp_enqueue_style( 'dark', get_template_directory_uri() . '/colors/dark.css', array(), null );
  1048. elseif ( 'blue' == $color_scheme )
  1049. wp_enqueue_style( 'blue', get_template_directory_uri() . '/colors/blue.css', array(), null );
  1050. do_action( 'catchbox_enqueue_color_scheme', $color_scheme );
  1051. }
  1052. add_action( 'wp_enqueue_scripts', 'catchbox_enqueue_color_scheme' );
  1053. /**
  1054. * Hooks the css to head section
  1055. *
  1056. * @since Catch Box 1.0
  1057. */
  1058. function catchbox_inline_css() {
  1059. $options = catchbox_get_theme_options();
  1060. if ( !empty( $options['custom_css'] ) ) {
  1061. echo '<!-- '.get_bloginfo('name').' Custom CSS Styles -->' . "\n";
  1062. echo '<style type="text/css" media="screen">' . "\n";
  1063. echo $options['custom_css'] . "\n";
  1064. echo '</style>' . "\n";
  1065. }
  1066. }
  1067. add_action('wp_head', 'catchbox_inline_css');
  1068. /**
  1069. * Site Verification codes are hooked to wp_head if any value exists
  1070. */
  1071. function catchbox_verification() {
  1072. $options = get_option('catchbox_options_webmaster');
  1073. //google
  1074. if ($options['google_verification']) {
  1075. echo '<meta name="google-site-verification" content="' . $options['google_verification'] . '" />' . "\n";
  1076. }
  1077. //bing
  1078. if ($options['bing_verification']) {
  1079. echo '<meta name="msvalidate.01" content="' . $options['bing_verification'] . '" />' . "\n";
  1080. }
  1081. //yahoo
  1082. if ($options['yahoo_verification']) {
  1083. echo '<meta name="y_key" content="' . $options['yahoo_verification'] . '" />' . "\n";
  1084. }
  1085. //site stats, analytics code
  1086. if ($options['tracker_header']) {
  1087. echo $options['tracker_header'];
  1088. }
  1089. }
  1090. add_action('wp_head', 'catchbox_verification');
  1091. /**
  1092. * Analytic, site stat code hooked in footer
  1093. * @uses wp_footer
  1094. */
  1095. function catchbox_site_stats() {
  1096. $options = get_option('catchbox_options_webmaster');
  1097. if ($options['tracker_footer']) {
  1098. echo $options['tracker_footer'];
  1099. }
  1100. }
  1101. add_action('wp_footer', 'catchbox_site_stats');
  1102. /**
  1103. * Add a style block to the theme for the current link color.
  1104. *
  1105. * This function is attached to the wp_head action hook.
  1106. *
  1107. * @since Catch Box 1.0
  1108. */
  1109. function catchbox_print_link_color_style() {
  1110. $options = catchbox_get_theme_options();
  1111. $link_color = $options['link_color'];
  1112. $default_options = catchbox_get_default_theme_options();
  1113. // Don't do anything if the current link color is the default.
  1114. if ( $default_options['link_color'] == $link_color )
  1115. return;
  1116. ?>
  1117. <style>
  1118. /* Link color */
  1119. a,
  1120. #site-title a:focus,
  1121. #site-title a:hover,
  1122. #site-title a:active,
  1123. .entry-title a:hover,
  1124. .entry-title a:focus,
  1125. .entry-title a:active,
  1126. .widget_catchbox_ephemera .comments-link a:hover,
  1127. section.recent-posts .other-recent-posts a[rel="bookmark"]:hover,
  1128. section.recent-posts .other-recent-posts .comments-link a:hover,
  1129. .format-image footer.entry-meta a:hover,
  1130. #site-generator a:hover {
  1131. color: <?php echo $link_color; ?>;
  1132. }
  1133. section.recent-posts .other-recent-posts .comments-link a:hover {
  1134. border-color: <?php echo $link_color; ?>;
  1135. }
  1136. article.feature-image.small .entry-summary p a:hover,
  1137. .entry-header .comments-link a:hover,
  1138. .entry-header .comments-link a:focus,
  1139. .entry-header .comments-link a:active,
  1140. .feature-slider a.active {
  1141. background-color: <?php echo $link_color; ?>;
  1142. }
  1143. </style>
  1144. <?php
  1145. }
  1146. add_action( 'wp_head', 'catchbox_print_link_color_style' );
  1147. /**
  1148. * Social Profles are hooked to catchbox_startgenerator_open if any value exists
  1149. *
  1150. * @since Catch Box 1.0
  1151. */
  1152. function catchbox_socialprofile() {
  1153. //delete_transient( 'catchbox_socialprofile' );
  1154. $options = get_option('catchbox_options_social_links');
  1155. $flag = 0;
  1156. if( !empty( $options ) ) {
  1157. foreach( $options as $option ) {
  1158. if( $option ) {
  1159. $flag = 1;
  1160. }
  1161. else {
  1162. $flag = 0;
  1163. }
  1164. if( $flag == 1) {
  1165. break;
  1166. }
  1167. }
  1168. }
  1169. if( ( !$catchbox_socialprofile = get_transient( 'catchbox_socialprofile' ) ) && ($flag == 1) ) {
  1170. echo '<!-- refreshing cache -->';
  1171. $catchbox_socialprofile = '
  1172. <div class="social-profile">
  1173. <ul>';
  1174. //Facebook
  1175. if ($options['social_facebook']) {
  1176. $catchbox_socialprofile .= '<li class="facebook"><a href="'.$options['social_facebook'].'" title="Facebook" target="_blank">Facebook</a></li>';
  1177. }
  1178. //Twitter
  1179. if ($options['social_twitter']) {
  1180. $catchbox_socialprofile .= '<li class="twitter"><a href="'.$options['social_twitter'].'" title="Twitter" target="_blank">Twitter</a></li>';
  1181. }
  1182. //Google+
  1183. if ($options['social_google']) {
  1184. $catchbox_socialprofile .= '<li class="google-plus"><a href="'.$options['social_google'].'" title="Google Plus" target="_blank">Google Plus</a></li>';
  1185. }
  1186. //Linkedin
  1187. if ($options['social_linkedin']) {
  1188. $catchbox_socialprofile .= '<li class="linkedin"><a href="'.$options['social_linkedin'].'" title="Linkedin" target="_blank">Linkedin</a></li>';
  1189. }
  1190. //Pinterest
  1191. if ($options['social_pinterest']) {
  1192. $catchbox_socialprofile .= '<li class="pinterest"><a href="'.$options['social_pinterest'].'" title="Pinterest" target="_blank">Pinterest</a></li>';
  1193. }
  1194. //Youtube
  1195. if ($options['social_youtube']) {
  1196. $catchbox_socialprofile .= '<li class="you-tube"><a href="'.$options['social_youtube'].'" title="YouTube" target="_blank">YouTube</a></li>';
  1197. }
  1198. //RSS Feed
  1199. if ($options['social_rss']) {
  1200. $catchbox_socialprofile .= '<li class="rss"><a href="'.$options['social_rss'].'" title="RSS Feed" target="_blank">RSS Feed</a></li>';
  1201. }
  1202. //Deviantart
  1203. if ($options['social_deviantart']) {
  1204. $catchbox_socialprofile .= '<li class="deviantart"><a href="'.$options['social_deviantart'].'" title="Deviantart" target="_blank">Deviantart</a></li>';
  1205. }
  1206. //Tumblr
  1207. if ($options['social_tumblr']) {
  1208. $catchbox_socialprofile .= '<li class="tumblr"><a href="'.$options['social_tumblr'].'" title="Tumblr" target="_blank">Tumblr</a></li>';
  1209. }
  1210. //Vimeo
  1211. if ($options['social_viemo']) {
  1212. $catchbox_socialprofile .= '<li class="vimeo"><a href="'.$options['social_viemo'].'" title="Vimeo" target="_blank">Vimeo</a></li>';
  1213. }
  1214. //Dribbble
  1215. if ($options['social_dribbble']) {
  1216. $catchbox_socialprofile .= '<li class="dribbble"><a href="'.$options['social_dribbble'].'" title="Dribbble" target="_blank">Dribbble</a></li>';
  1217. }
  1218. //MySpace
  1219. if ($options['social_myspace']) {
  1220. $catchbox_socialprofile .= '<li class="my-space"><a href="'.$options['social_myspace'].'" title="MySpace" target="_blank">MySpace</a></li>';
  1221. }
  1222. //Aim
  1223. if ($options['social_aim']) {
  1224. $catchbox_socialprofile .= '<li class="aim"><a href="'.$options['social_aim'].'" title="Aim" target="_blank">Aim</a></li>';
  1225. }
  1226. //Flickr
  1227. if ($options['social_flickr']) {
  1228. $catchbox_socialprofile .= '<li class="flickr"><a href="'.$options['social_flickr'].'" title="Flickr" target="_blank">Flickr</a></li>';
  1229. }
  1230. $catchbox_socialprofile .= '
  1231. </ul>
  1232. </div>';
  1233. set_transient( 'catchbox_socialprofile', $catchbox_socialprofile, 604800 );
  1234. }
  1235. echo $catchbox_socialprofile;
  1236. } // catchbox_socialprofile
  1237. add_action('catchbox_startgenerator_open', 'catchbox_socialprofile');
  1238. /**
  1239. * Redirect WordPress Feeds To FeedBurner
  1240. */
  1241. function catchbox_rss_redirect() {
  1242. $options = catchbox_get_theme_options();
  1243. if ( !empty( $options['feed_url'] ) ) {
  1244. $url = 'Location: '.$options['feed_url'];
  1245. if ( is_feed() && !preg_match('/feedburner|feedvalidator/i', $_SERVER['HTTP_USER_AGENT']))
  1246. {
  1247. header($url);
  1248. header('HTTP/1.1 302 Temporary Redirect');
  1249. }
  1250. }
  1251. }
  1252. add_action('template_redirect', 'catchbox_rss_redirect');
  1253. /* Clearing Theme Option Cache
  1254. * @uses delete_transient
  1255. */
  1256. function catchbox_themeoption_invalidate_caches() {
  1257. delete_transient( 'catchbox_favicon' ); //Favicon
  1258. delete_transient( 'catchbox_sliders' ); // Featured Slider
  1259. delete_transient( 'catchbox_socialprofile' ); //Social Profile
  1260. delete_transient( 'catchbox_webclip' ); //Favicon
  1261. }
  1262. /* Clearing Theme Option Cache
  1263. * @uses delete_transient and action publish_post
  1264. */
  1265. function catchbox_posts_invalidate_caches() {
  1266. delete_transient( 'catchbox_sliders' ); // Featured Slider
  1267. }
  1268. add_action( 'publish_post', 'catchbox_posts_invalidate_caches' ); // publish posts runs whenever posts are published or published posts are edited