/wp-content/themes/bladencountyrecords/functions/admin-setup.php

https://gitlab.com/blueprintmrk/bladencountyrecords · PHP · 275 lines · 164 code · 47 blank · 64 comment · 56 complexity · c92f73fa96f7b52ee645f76be690eadb MD5 · raw file

  1. <?php
  2. /*-----------------------------------------------------------------------------------
  3. TABLE OF CONTENTS
  4. - Show Options Panel after activate
  5. - Admin Backend
  6. - Setup Custom Navigation
  7. - Output HEAD - woothemes_wp_head()
  8. - Output alternative stylesheet
  9. - Output custom favicon
  10. - Load textdomains
  11. - Output CSS from standarized styling options
  12. - Output shortcodes stylesheet
  13. - Output custom.css
  14. - Post Images from WP2.9+ integration
  15. - Enqueue comment reply script
  16. -----------------------------------------------------------------------------------*/
  17. define( 'THEME_FRAMEWORK','woothemes' );
  18. /*-----------------------------------------------------------------------------------*/
  19. /* Add default options and show Options Panel after activate */
  20. /*-----------------------------------------------------------------------------------*/
  21. if (is_admin() && isset($_GET['activated'] ) && $pagenow == "themes.php" ) {
  22. //Call action that sets
  23. add_action( 'admin_head','woo_option_setup' );
  24. //Do redirect
  25. header( 'Location: '.admin_url().'admin.php?page=woothemes' ) ;
  26. }
  27. if (!function_exists( 'woo_option_setup')) {
  28. function woo_option_setup(){
  29. //Update EMPTY options
  30. $woo_array = array();
  31. add_option( 'woo_options',$woo_array);
  32. $template = get_option( 'woo_template' );
  33. $saved_options = get_option( 'woo_options' );
  34. foreach ( (array) $template as $option ) {
  35. if ($option['type'] != 'heading'){
  36. $id = $option['id'];
  37. $std = isset( $option['std'] ) ? $option['std'] : NULL;
  38. $db_option = get_option($id);
  39. if (empty($db_option)){
  40. if (is_array($option['type'])) {
  41. foreach ($option['type'] as $child){
  42. $c_id = $child['id'];
  43. $c_std = $child['std'];
  44. $db_option = get_option($c_id);
  45. if (!empty($db_option)){
  46. update_option($c_id,$db_option);
  47. $woo_array[$id] = $db_option;
  48. } else {
  49. $woo_array[$c_id] = $c_std;
  50. }
  51. }
  52. } else {
  53. update_option($id,$std);
  54. $woo_array[$id] = $std;
  55. }
  56. } else { //So just store the old values over again.
  57. $woo_array[$id] = $db_option;
  58. }
  59. }
  60. }
  61. update_option( 'woo_options',$woo_array);
  62. }
  63. }
  64. /*-----------------------------------------------------------------------------------*/
  65. /* Admin Backend */
  66. /*-----------------------------------------------------------------------------------*/
  67. if (!function_exists( 'woothemes_admin_head')) {
  68. function woothemes_admin_head() {
  69. //Setup Custom Navigation Menu
  70. if (function_exists( 'woo_custom_navigation_setup')) {
  71. woo_custom_navigation_setup();
  72. }
  73. }
  74. }
  75. add_action( 'admin_head', 'woothemes_admin_head' );
  76. /*-----------------------------------------------------------------------------------*/
  77. /* Output HEAD - woothemes_wp_head */
  78. /*-----------------------------------------------------------------------------------*/
  79. if (!function_exists( 'woothemes_wp_head')) {
  80. function woothemes_wp_head() {
  81. // Output alternative stylesheet
  82. if ( function_exists( 'woo_output_alt_stylesheet' ) )
  83. woo_output_alt_stylesheet();
  84. // Output custom favicon
  85. if ( function_exists( 'woo_output_custom_favicon' ) )
  86. woo_output_custom_favicon();
  87. // Output CSS from standarized styling options
  88. if ( function_exists( 'woo_head_css' ) )
  89. woo_head_css();
  90. // Output shortcodes stylesheet
  91. if ( function_exists( 'woo_shortcode_stylesheet' ) )
  92. woo_shortcode_stylesheet();
  93. // Output custom.css
  94. if ( function_exists( 'woo_output_custom_css' ) )
  95. woo_output_custom_css();
  96. }
  97. }
  98. add_action( 'wp_head', 'woothemes_wp_head' );
  99. /*-----------------------------------------------------------------------------------*/
  100. /* Output alternative stylesheet - woo_output_alt_stylesheet */
  101. /*-----------------------------------------------------------------------------------*/
  102. if (!function_exists( 'woo_output_alt_stylesheet')) {
  103. function woo_output_alt_stylesheet() {
  104. $style = '';
  105. if ( isset( $_REQUEST['style'] ) ) {
  106. // Sanitize requested value.
  107. $requested_style = strtolower( strip_tags( trim( $_REQUEST['style'] ) ) );
  108. $style = $requested_style;
  109. }
  110. echo "<!-- Alt Stylesheet -->\n";
  111. if ($style != '') {
  112. echo '<link href="'. get_template_directory_uri() . '/styles/'. $style . '.css" rel="stylesheet" type="text/css" />'."\n\n";
  113. } else {
  114. $style = get_option( 'woo_alt_stylesheet' );
  115. if( $style != '' ) {
  116. // Sanitize value.
  117. $style = strtolower( strip_tags( trim( $style ) ) );
  118. echo '<link href="'. get_template_directory_uri() . '/styles/'. $style .'" rel="stylesheet" type="text/css" />'."\n\n";
  119. } else {
  120. echo '<link href="'. get_template_directory_uri() . '/styles/default.css" rel="stylesheet" type="text/css" />'."\n\n";
  121. }
  122. }
  123. }
  124. }
  125. /*-----------------------------------------------------------------------------------*/
  126. /* Output favicon link - woo_custom_favicon() */
  127. /*-----------------------------------------------------------------------------------*/
  128. if ( ! function_exists( 'woo_output_custom_favicon' ) ) {
  129. function woo_output_custom_favicon() {
  130. // Favicon
  131. if(get_option( 'woo_custom_favicon') != '') {
  132. echo "<!-- Custom Favicon -->\n";
  133. echo '<link rel="shortcut icon" href="' . get_option( 'woo_custom_favicon' ) . '"/>'."\n\n";
  134. }
  135. }
  136. }
  137. /*-----------------------------------------------------------------------------------*/
  138. /* Load textdomain - woo_load_textdomain() */
  139. /*-----------------------------------------------------------------------------------*/
  140. if ( ! function_exists( 'woo_load_textdomain' ) ) {
  141. function woo_load_textdomain() {
  142. load_theme_textdomain( 'woothemes' );
  143. load_theme_textdomain( 'woothemes', get_template_directory() . '/lang' );
  144. if ( function_exists( 'load_child_theme_textdomain' ) )
  145. load_child_theme_textdomain( 'woothemes' );
  146. }
  147. }
  148. add_action( 'init', 'woo_load_textdomain' );
  149. /*-----------------------------------------------------------------------------------*/
  150. /* Output CSS from standarized options */
  151. /*-----------------------------------------------------------------------------------*/
  152. if ( ! function_exists( 'woo_head_css' ) ) {
  153. function woo_head_css() {
  154. $output = '';
  155. $text_title = get_option( 'woo_texttitle' );
  156. $tagline = get_option( 'woo_tagline' );
  157. $custom_css = get_option( 'woo_custom_css' );
  158. $template = get_option( 'woo_template' );
  159. if (is_array($template)) {
  160. foreach($template as $option){
  161. if(isset($option['id'])){
  162. if($option['id'] == 'woo_texttitle') {
  163. // Add CSS to output
  164. if ( $text_title == "true" ) {
  165. $output .= '#logo img { display:none; } #logo .site-title { display:block; }' . "\n";
  166. if ( $tagline == "false" )
  167. $output .= '#logo .site-description { display:none; }' . "\n";
  168. else
  169. $output .= '#logo .site-description { display:block; }' . "\n";
  170. }
  171. }
  172. }
  173. }
  174. }
  175. if ($custom_css <> '') {
  176. $output .= $custom_css . "\n";
  177. }
  178. // Output styles
  179. if ($output <> '') {
  180. $output = strip_tags($output);
  181. echo "<!-- Options Panel Custom CSS -->\n";
  182. $output = "<style type=\"text/css\">\n" . $output . "</style>\n\n";
  183. echo $output;
  184. }
  185. }
  186. }
  187. /*-----------------------------------------------------------------------------------*/
  188. /* Output custom.css - woo_custom_css() */
  189. /*-----------------------------------------------------------------------------------*/
  190. if (!function_exists( 'woo_output_custom_css')) {
  191. function woo_output_custom_css() {
  192. // Custom.css insert
  193. echo "<!-- Custom Stylesheet -->\n";
  194. echo '<link href="'. get_template_directory_uri() . '/custom.css" rel="stylesheet" type="text/css" />'."\n";
  195. }
  196. }
  197. /*-----------------------------------------------------------------------------------*/
  198. /* Post Images from WP2.9+ integration /*
  199. /*-----------------------------------------------------------------------------------*/
  200. if(function_exists( 'add_theme_support')){
  201. if(get_option( 'woo_post_image_support') == 'true'){
  202. add_theme_support( 'post-thumbnails' );
  203. // set height, width and crop if dynamic resize functionality isn't enabled
  204. if ( get_option( 'woo_pis_resize') != 'true' ) {
  205. $thumb_width = get_option( 'woo_thumb_w' );
  206. $thumb_height = get_option( 'woo_thumb_h' );
  207. $single_width = get_option( 'woo_single_w' );
  208. $single_height = get_option( 'woo_single_h' );
  209. $hard_crop = get_option( 'woo_pis_hard_crop' );
  210. if($hard_crop == 'true') {$hard_crop = true; } else { $hard_crop = false;}
  211. set_post_thumbnail_size($thumb_width,$thumb_height, $hard_crop); // Normal post thumbnails
  212. add_image_size( 'single-post-thumbnail', $single_width, $single_height, $hard_crop );
  213. }
  214. }
  215. }
  216. /*-----------------------------------------------------------------------------------*/
  217. /* Enqueue comment reply script */
  218. /*-----------------------------------------------------------------------------------*/
  219. if (!function_exists( 'woo_comment_reply')) {
  220. function woo_comment_reply() {
  221. if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
  222. }
  223. }
  224. add_action( 'get_header', 'woo_comment_reply' );
  225. ?>