Advertisement
Guest User

DB-DB-Function

a guest
Feb 20th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.99 KB | None | 0 0
  1. <?php
  2. add_action( 'after_setup_theme', 'et_setup_theme' );
  3. if ( ! function_exists( 'et_setup_theme' ) ){
  4. function et_setup_theme(){
  5. global $themename, $shortname, $et_store_options_in_one_row;
  6. $themename = 'Lucid';
  7. $shortname = 'lucid';
  8. $et_store_options_in_one_row = true;
  9.  
  10. require_once(TEMPLATEPATH . '/epanel/custom_functions.php');
  11.  
  12. require_once(TEMPLATEPATH . '/includes/functions/comments.php');
  13.  
  14. require_once(TEMPLATEPATH . '/includes/functions/sidebars.php');
  15.  
  16. load_theme_textdomain('Lucid',get_template_directory().'/lang');
  17.  
  18. require_once(TEMPLATEPATH . '/epanel/options_lucid.php');
  19.  
  20. require_once(TEMPLATEPATH . '/epanel/core_functions.php');
  21.  
  22. require_once(TEMPLATEPATH . '/epanel/post_thumbnails_lucid.php');
  23.  
  24. include(TEMPLATEPATH . '/includes/widgets.php');
  25.  
  26. require_once(TEMPLATEPATH . '/includes/additional_functions.php');
  27.  
  28. add_action( 'init', 'et_register_main_menus' );
  29.  
  30. add_action( 'wp_enqueue_scripts', 'et_load_lucid_scripts' );
  31.  
  32. add_action( 'wp_enqueue_scripts', 'et_add_google_fonts' );
  33.  
  34. add_action( 'wp_head', 'et_add_viewport_meta' );
  35.  
  36. add_action( 'pre_get_posts', 'et_home_posts_query' );
  37.  
  38. add_action( 'et_epanel_changing_options', 'et_delete_featured_ids_cache' );
  39. add_action( 'delete_post', 'et_delete_featured_ids_cache' );
  40. add_action( 'save_post', 'et_delete_featured_ids_cache' );
  41.  
  42. add_filter( 'wp_page_menu_args', 'et_add_home_link' );
  43.  
  44. add_filter( 'et_get_additional_color_scheme', 'et_remove_additional_stylesheet' );
  45.  
  46. add_theme_support( 'post-formats', array( 'video' ) );
  47.  
  48. add_filter( 'body_class', 'et_sidebar_left_class' );
  49.  
  50. add_action( 'wp_head', 'et_color_schemes_styles' );
  51.  
  52. add_action( 'et_header_menu', 'et_add_mobile_navigation' );
  53.  
  54. add_action( 'et_secondary_menu', 'et_add_secondary_mobile_navigation' );
  55.  
  56. add_action( 'wp_enqueue_scripts', 'et_add_responsive_shortcodes_css', 11 );
  57. }
  58. }
  59.  
  60. function et_register_main_menus() {
  61. register_nav_menus(
  62. array(
  63. 'primary-menu' => __( 'Primary Menu', 'Lucid' ),
  64. 'secondary-menu' => __( 'Secondary Menu', 'Lucid' ),
  65. 'footer-menu' => __( 'Footer Menu', 'Lucid' )
  66. )
  67. );
  68. }
  69.  
  70. function et_add_home_link( $args ) {
  71. // add Home link to the custom menu WP-Admin page
  72. $args['show_home'] = true;
  73. return $args;
  74. }
  75.  
  76. function et_sidebar_left_class( $body_classes ){
  77. global $post;
  78.  
  79. if ( is_singular() && 'on' == get_post_meta( $post->ID, '_et_left_sidebar', true ) ) $body_classes[] = 'et_left_sidebar';
  80.  
  81. if ( is_home() && 'on' == et_get_option( 'lucid_home_left_sidebar', 'false' ) ) $body_classes[] = 'et_left_sidebar';
  82.  
  83. return $body_classes;
  84. }
  85.  
  86. function et_add_mobile_navigation(){
  87. echo '<a href="#" class="mobile_nav closed">' . esc_html__( 'Pages Menu', 'Lucid' ) . '<span></span></a>';
  88. }
  89.  
  90. function et_add_secondary_mobile_navigation(){
  91. echo '<a href="#" class="mobile_nav closed">' . esc_html__( 'Categories Menu', 'Lucid' ) . '<span></span></a>';
  92. }
  93.  
  94. function et_color_schemes_styles(){
  95. $color_scheme = et_get_option( 'lucid_color_scheme', 'Orange' );
  96. $theme_folder = trailingslashit( get_template_directory_uri() );
  97.  
  98. echo '<style>';
  99. if ( 'Orange' == $color_scheme ){
  100. echo "
  101. #featured .flex-direction-nav a:hover, #video-slider-section .flex-direction-nav a:hover { background-color: #ffb600; }
  102. #featured_section .active-slide .post-meta, #featured_section .switcher_hover .post-meta, .et_tab_link_hover .post-meta { background: #ffa500; }
  103. h3.main-title { background-color: #ffa500; -moz-box-shadow: inset 0 0 10px rgba(255,140,0,0.1); -webkit-box-shadow: inset 0 0 10px rgba(255,140,0,0.1); box-shadow: inset 0 0 10px rgba(255,140,0,0.1); border: 1px solid #ff8c00; }
  104. .widget li { background: url({$theme_folder}images/widget-bullet.png) no-repeat 24px 24px; }
  105. .footer-widget li { background: url({$theme_folder}images/widget-bullet.png) no-repeat 0 4px; }
  106. .et_mobile_menu li a { background-image: url({$theme_folder}images/widget-bullet.png); }
  107. a { color: #ffa300; }
  108. .et_video_play { background-color: #ffa500; }
  109. #second-menu > ul > li > a:hover { background-color: #ffa500; }
  110. #second-menu ul ul li a:hover { background-color: #ffb122; }
  111. #second-menu ul.nav li ul { background: #ffa500; }
  112. #second-menu ul ul li a { border-top: 1px solid #ffb122; }
  113. ";
  114. } elseif ( 'Blue' == $color_scheme ){
  115. echo "
  116. #featured .flex-direction-nav a:hover, #video-slider-section .flex-direction-nav a:hover { background-color: #00befe; }
  117. #featured_section .active-slide .post-meta, #featured_section .switcher_hover .post-meta, .et_tab_link_hover .post-meta { background: #009cff; }
  118. h3.main-title { background-color: #009cff; -moz-box-shadow: inset 0 0 10px rgba(0,133,245,0.1); -webkit-box-shadow: inset 0 0 10px rgba(0,133,245,0.1); box-shadow: inset 0 0 10px rgba(0,133,245,0.1); border: 1px solid #0085f5; }
  119. .widget li { background: url({$theme_folder}images/widget-blue-bullet.png) no-repeat 24px 24px; }
  120. .footer-widget li { background: url({$theme_folder}images/widget-blue-bullet.png) no-repeat 0 4px; }
  121. .et_mobile_menu li a { background-image: url({$theme_folder}images/widget-blue-bullet.png); }
  122. a { color: #009cff; }
  123. .et_video_play { background-color: #009cff; }
  124. #second-menu > ul > li > a:hover { background-color: #009cff; -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); box-shadow: inset 0 0 10px rgba(0,0,0,0.3); }
  125. #second-menu ul ul li a:hover { background-color: #33b0ff; }
  126. #second-menu ul.nav li ul { background: #009cff; }
  127. #second-menu ul ul li a { border-top: 1px solid #33b0ff; }
  128. ";
  129. } elseif ( 'Green' == $color_scheme ) {
  130. echo "
  131. #featured .flex-direction-nav a:hover, #video-slider-section .flex-direction-nav a:hover { background-color: #66e700; }
  132. #featured_section .active-slide .post-meta, #featured_section .switcher_hover .post-meta, .et_tab_link_hover .post-meta { background: #31d200; }
  133. h3.main-title { background-color: #31d200; -moz-box-shadow: inset 0 0 10px rgba(38,184,0,0.1); -webkit-box-shadow: inset 0 0 10px rgba(38,184,0,0.1); box-shadow: inset 0 0 10px rgba(38,184,0,0.1); border: 1px solid #26b800; }
  134. .widget li { background: url({$theme_folder}images/widget-green-bullet.png) no-repeat 24px 24px; }
  135. .footer-widget li { background: url({$theme_folder}images/widget-green-bullet.png) no-repeat 0 4px; }
  136. .et_mobile_menu li a { background-image: url({$theme_folder}images/widget-green-bullet.png); }
  137. a { color: #31d200; }
  138. .et_video_play { background-color: #31d200; }
  139. #second-menu > ul > li > a:hover { background-color: #31d200; -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); box-shadow: inset 0 0 10px rgba(0,0,0,0.3); }
  140. #second-menu ul ul li a:hover { background-color: #36e600; }
  141. #second-menu ul.nav li ul { background: #31d200; }
  142. #second-menu ul ul li a { border-top: 1px solid #36e600; }
  143. ";
  144. } elseif ( 'Red' == $color_scheme ) {
  145. echo "
  146. #featured .flex-direction-nav a:hover, #video-slider-section .flex-direction-nav a:hover { background-color: #66e700; }
  147. #featured_section .active-slide .post-meta, #featured_section .switcher_hover .post-meta, .et_tab_link_hover .post-meta { background: #f00d0d; }
  148. h3.main-title { background-color: #f00d0d; -moz-box-shadow: inset 0 0 10px rgba(207,8,8,0.1); -webkit-box-shadow: inset 0 0 10px rgba(207,8,8,0.1); box-shadow: inset 0 0 10px rgba(207,8,8,0.1); border: 1px solid #cf0808; }
  149. .widget li { background: url({$theme_folder}images/widget-red-bullet.png) no-repeat 24px 24px; }
  150. .footer-widget li { background: url({$theme_folder}images/widget-red-bullet.png) no-repeat 0 4px; }
  151. .et_mobile_menu li a { background-image: url({$theme_folder}images/widget-red-bullet.png); }
  152. a { color: #f00d0d; }
  153. .et_video_play { background-color: #f00d0d; }
  154. #second-menu > ul > li > a:hover { background-color: #f00d0d; -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); box-shadow: inset 0 0 10px rgba(0,0,0,0.3); }
  155. #second-menu ul ul li a:hover { background-color: #f72b2b; }
  156. #second-menu ul.nav li ul { background: #f00d0d; }
  157. #second-menu ul ul li a { border-top: 1px solid #f72b2b; }
  158. ";
  159. } elseif ( 'Purple' == $color_scheme ) {
  160. echo "
  161. #featured .flex-direction-nav a:hover, #video-slider-section .flex-direction-nav a:hover { background-color: #de3ef7; }
  162. #featured_section .active-slide .post-meta, #featured_section .switcher_hover .post-meta, .et_tab_link_hover .post-meta { background: #c30df0; }
  163. h3.main-title { background-color: #c30df0; -moz-box-shadow: inset 0 0 10px rgba(171,11,210,0.1); -webkit-box-shadow: inset 0 0 10px rgba(171,11,210,0.1); box-shadow: inset 0 0 10px rgba(171,11,210,0.1); border: 1px solid #ab0bd2; }
  164. .widget li { background: url({$theme_folder}images/widget-purple-bullet.png) no-repeat 24px 24px; }
  165. .footer-widget li { background: url({$theme_folder}images/widget-purple-bullet.png) no-repeat 0 4px; }
  166. .et_mobile_menu li a { background-image: url({$theme_folder}images/widget-purple-bullet.png); }
  167. a { color: #c30df0; }
  168. .et_video_play { background-color: #c30df0; }
  169. #second-menu > ul > li > a:hover { background-color: #c30df0; -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.3); box-shadow: inset 0 0 10px rgba(0,0,0,0.3); }
  170. #second-menu ul ul li a:hover { background-color: #cd29f6; }
  171. #second-menu ul.nav li ul { background: #c30df0; }
  172. #second-menu ul ul li a { border-top: 1px solid #cd29f6; }
  173. ";
  174. }
  175.  
  176. echo '</style>';
  177. }
  178.  
  179. function et_load_lucid_scripts(){
  180. if ( !is_admin() ){
  181. $template_dir = get_template_directory_uri();
  182.  
  183. wp_enqueue_script('superfish', $template_dir . '/js/superfish.js', array('jquery'), '1.0', true);
  184. wp_enqueue_script('flexslider', $template_dir . '/js/jquery.flexslider-min.js', array('jquery'), '1.0', true);
  185. wp_enqueue_script('fitvids', $template_dir . '/js/jquery.fitvids.js', array('jquery'), '1.0', true);
  186. wp_enqueue_script('custom_script', $template_dir . '/js/custom.js', array('jquery'), '1.0', true);
  187. }
  188. if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' );
  189. }
  190.  
  191. function et_add_google_fonts(){
  192. wp_enqueue_style( 'google_font_open_sans', 'http://fonts.googleapis.com/css?family=Open+Sans:400,700,300' );
  193. wp_enqueue_style( 'google_font_open_sans_condensed', 'http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700' );
  194. }
  195.  
  196. function et_add_viewport_meta(){
  197. echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />';
  198. }
  199.  
  200. function et_remove_additional_stylesheet( $stylesheet ){
  201. global $default_colorscheme;
  202. return $default_colorscheme;
  203. }
  204.  
  205. /**
  206. * Gets featured posts IDs from transient, if the transient doesn't exist - runs the query and stores IDs
  207. */
  208. function et_get_featured_posts_ids(){
  209. if ( false === ( $et_featured_post_ids = get_transient( 'et_featured_post_ids' ) ) ) {
  210. $featured_query = new WP_Query( apply_filters( 'et_featured_post_args', array(
  211. 'posts_per_page' => (int) et_get_option( 'lucid_featured_num' ),
  212. 'cat' => get_catId( et_get_option( 'lucid_feat_posts_cat' ) )
  213. ) ) );
  214.  
  215. if ( $featured_query->have_posts() ) {
  216. while ( $featured_query->have_posts() ) {
  217. $featured_query->the_post();
  218.  
  219. $et_featured_post_ids[] = get_the_ID();
  220. }
  221.  
  222. set_transient( 'et_featured_post_ids', $et_featured_post_ids );
  223. }
  224.  
  225. wp_reset_postdata();
  226. }
  227.  
  228. return $et_featured_post_ids;
  229. }
  230.  
  231. /**
  232. * Filters the main query on homepage
  233. */
  234. function et_home_posts_query( $query = false ) {
  235. /* Don't proceed if it's not homepage or the main query */
  236. if ( ! is_home() || ! is_a( $query, 'WP_Query' ) || ! $query->is_main_query() ) return;
  237.  
  238. /* Set the amount of posts per page on homepage */
  239. $query->set( 'posts_per_page', et_get_option( 'lucid_homepage_posts', '6' ) );
  240.  
  241. /* Exclude categories set in ePanel */
  242. $exclude_categories = et_get_option( 'lucid_exlcats_recent', false );
  243. if ( $exclude_categories ) $query->set( 'category__not_in', $exclude_categories );
  244.  
  245. /* Exclude slider posts, if the slider is activated, pages are not featured and posts duplication is disabled in ePanel */
  246. if ( 'on' == et_get_option( 'lucid_featured', 'on' ) && 'false' == et_get_option( 'lucid_use_pages', 'false' ) && 'false' == et_get_option( 'lucid_duplicate', 'on' ) )
  247. $query->set( 'post__not_in', et_get_featured_posts_ids() );
  248. }
  249.  
  250. /**
  251. * Deletes featured posts IDs transient, when the user saves, resets ePanel settings, creates or moves posts to trash in WP-Admin
  252. */
  253. function et_delete_featured_ids_cache(){
  254. if ( false !== get_transient( 'et_featured_post_ids' ) ) delete_transient( 'et_featured_post_ids' );
  255. }
  256.  
  257. if ( ! function_exists( 'et_list_pings' ) ){
  258. function et_list_pings($comment, $args, $depth) {
  259. $GLOBALS['comment'] = $comment; ?>
  260. <li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?> - <?php comment_excerpt(); ?>
  261. <?php }
  262. }
  263.  
  264. if ( ! function_exists( 'et_get_the_author_posts_link' ) ){
  265. function et_get_the_author_posts_link(){
  266. global $authordata, $themename;
  267.  
  268. $link = sprintf(
  269. '<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
  270. get_author_posts_url( $authordata->ID, $authordata->user_nicename ),
  271. esc_attr( sprintf( __( 'Posts by %s', $themename ), get_the_author() ) ),
  272. get_the_author()
  273. );
  274. return apply_filters( 'the_author_posts_link', $link );
  275. }
  276. }
  277.  
  278. if ( ! function_exists( 'et_get_comments_popup_link' ) ){
  279. function et_get_comments_popup_link( $zero = false, $one = false, $more = false ){
  280. global $themename;
  281.  
  282. $id = get_the_ID();
  283. $number = get_comments_number( $id );
  284.  
  285. if ( 0 == $number && !comments_open() && !pings_open() ) return;
  286.  
  287. if ( $number > 1 )
  288. $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments', $themename) : $more);
  289. elseif ( $number == 0 )
  290. $output = ( false === $zero ) ? __('No Comments',$themename) : $zero;
  291. else // must be one
  292. $output = ( false === $one ) ? __('1 Comment', $themename) : $one;
  293.  
  294. return '<span class="comments-number">' . '<a href="' . esc_url( get_permalink() . '#respond' ) . '">' . apply_filters('comments_number', $output, $number) . '</a>' . '</span>';
  295. }
  296. }
  297.  
  298. if ( ! function_exists( 'et_postinfo_meta' ) ){
  299. function et_postinfo_meta( $postinfo, $date_format, $comment_zero, $comment_one, $comment_more ){
  300. global $themename;
  301.  
  302. $postinfo_meta = '';
  303.  
  304. if ( in_array( 'author', $postinfo ) ){
  305. $postinfo_meta .= ' ' . esc_html__('by',$themename) . ' ' . et_get_the_author_posts_link();
  306. }
  307.  
  308. if ( in_array( 'date', $postinfo ) )
  309. $postinfo_meta .= ' ' . esc_html__('on',$themename) . ' ' . get_the_time( $date_format );
  310.  
  311. if ( in_array( 'categories', $postinfo ) )
  312. $postinfo_meta .= ' ' . esc_html__('in',$themename) . ' ' . get_the_category_list(', ');
  313.  
  314. if ( in_array( 'comments', $postinfo ) )
  315. $postinfo_meta .= ' | ' . et_get_comments_popup_link( $comment_zero, $comment_one, $comment_more );
  316.  
  317. if ( '' != $postinfo_meta ) $postinfo_meta = __('Posted',$themename) . ' ' . $postinfo_meta;
  318.  
  319. echo $postinfo_meta;
  320. }
  321. }
  322.  
  323. // CUSTOM ADMIN LOGIN HEADER LOGO
  324.  
  325.  
  326. function my_custom_login_logo()
  327.  
  328. {
  329. echo '<style type="text/css"> h1 a { background-image:url(' . get_bloginfo('template_directory') . '/images/logo_admin.png) !important; } </style>';
  330.  
  331. }
  332. add_action('login_head', 'my_custom_login_logo');
  333.  
  334. // CUSTOM ADMIN LOGIN LOGO LINK
  335.  
  336.  
  337. function change_wp_login_url()
  338.  
  339. {
  340. echo bloginfo('http://www.DermBids.com'); // OR ECHO YOUR OWN URL
  341.  
  342. }
  343. add_filter('login_headerurl', 'change_wp_login_url');
  344.  
  345.  
  346.  
  347. // CUSTOM ADMIN LOGIN LOGO & ALT TEXT
  348.  
  349.  
  350. function change_wp_login_title()
  351.  
  352. {
  353. echo get_option('DermBids Login'); // OR ECHO YOUR OWN ALT TEXT
  354.  
  355. }
  356. add_filter('login_headertitle', 'change_wp_login_title');
  357.  
  358. // Admin footer modification
  359.  
  360. function remove_footer_admin ()
  361.  
  362. {
  363. echo '<span id="footer-thankyou">Developed by <a href="http://www.DermBids.com" target="_blank">DermBids Inc.</a></span>';
  364.  
  365. }
  366. add_filter('admin_footer_text', 'remove_footer_admin');
  367.  
  368. // example custom dashboard widget
  369. function custom_dashboard_widget() {
  370. echo "<p>Dearest Client, Here&rsquo;s how to do that thing I told you about yesterday...</p>";
  371. }
  372. function add_custom_dashboard_widget() {
  373. wp_add_dashboard_widget('custom_dashboard_widget', 'How to Do Something in WordPress', 'custom_dashboard_widget');
  374. }
  375. add_action('wp_dashboard_setup', 'add_custom_dashboard_widget');
  376. // from wordpress.org
  377. // Create the function to output the contents of our Dashboard Widget
  378.  
  379. function example_dashboard_widget_function() {
  380. // Display whatever it is you want to show
  381. echo "Hello World, I'm a great Dashboard Widget";
  382. }
  383.  
  384. // Create the function use in the action hook
  385.  
  386. function example_add_dashboard_widgets() {
  387. wp_add_dashboard_widget('example_dashboard_widget', 'Example Dashboard Widget', 'example_dashboard_widget_function');
  388. }
  389.  
  390. // Hook into the 'wp_dashboard_setup' action to register our other functions
  391.  
  392. add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' ); // Hint: For Multisite Network Admin Dashboard use wp_network_dashboard_setup instead of wp_dashboard_setup.
  393.  
  394. // WordPress Support
  395. function example_dashboard_widget_function() {
  396.  
  397. $posts = get_posts('category_name=chicago&posts_per_page=-1');
  398.  
  399. if($posts){
  400. echo '<p>';
  401. foreach ($posts as $post) {
  402. echo '<a href="' . get_edit_post_link( $post->ID) . '">' . $post->post_title .'</a><br/>';
  403. }
  404. echo '</p>';
  405. }
  406. }
  407.  
  408. // Create the function use in the action hook
  409.  
  410. function example_add_dashboard_widgets() {
  411. wp_add_dashboard_widget('example_dashboard_widget', 'Category Chicago', 'example_dashboard_widget_function');
  412. }
  413.  
  414. // Hook into the 'wp_dashboard_setup' action to register our other functions
  415.  
  416. add_action('wp_dashboard_setup', 'example_add_dashboard_widgets' ); // Hint: For Multisite Network Admin Dashboard use wp_network_dashboard_setup instead of wp_dashboard_setup.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement