Advertisement
Guest User

Untitled

a guest
Jan 7th, 2012
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.44 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. include 'theme_options.php';
  6.  
  7. include 'guide.php';
  8.  
  9. include 'breadcrumbs.php';
  10.  
  11. include 'lib/metabox.php';
  12.  
  13. include 'lib/post-types.php';
  14.  
  15.  
  16.  
  17. /* SIDEBARS *///////////////////////////////////////////////////////////////
  18.  
  19.  
  20.  
  21. if ( function_exists('register_sidebar') )
  22.  
  23.  
  24.  
  25. register_sidebar(array(
  26.  
  27. 'name' => 'Sidebar',
  28.  
  29. 'before_widget' => '<li class="sidebox %2$s">',
  30.  
  31. 'after_widget' => '</li>',
  32.  
  33. 'before_title' => '<h3 class="sidetitl">',
  34.  
  35. 'after_title' => '</h3>',
  36.  
  37.  
  38.  
  39. ));
  40.  
  41.  
  42.  
  43.  
  44.  
  45. /* CUSTOM MENUS */////////////////////////////////////////////////////////////////
  46.  
  47.  
  48.  
  49. register_nav_menus( array(
  50.  
  51. 'primary' => __( 'Primary Navigation', '' ),
  52.  
  53. ) );
  54.  
  55.  
  56.  
  57. function fallbackmenu(){ ?>
  58.  
  59. <div id="submenu">
  60.  
  61. <ul><li> Go to Adminpanel > Appearance > Menus to create your menu. You should have WP 3.0+ version for custom menus to work.</li></ul>
  62.  
  63. </div>
  64.  
  65. <?php }
  66.  
  67.  
  68.  
  69.  
  70.  
  71. /* CUSTOM EXCERPTS *///////////////////////////////////////////////////////////////
  72.  
  73.  
  74.  
  75.  
  76.  
  77. function wpe_excerptlength_archive($length) {
  78.  
  79. return 60;
  80.  
  81. }
  82.  
  83. function wpe_excerptlength_index($length) {
  84.  
  85. return 70;
  86.  
  87. }
  88.  
  89. function wpe_excerptlength_slide($length) {
  90.  
  91. return 40;
  92.  
  93. }
  94.  
  95.  
  96.  
  97. function wpe_excerpt($length_callback='', $more_callback='') {
  98.  
  99. global $post;
  100.  
  101. if(function_exists($length_callback)){
  102.  
  103. add_filter('excerpt_length', $length_callback);
  104.  
  105. }
  106.  
  107. if(function_exists($more_callback)){
  108.  
  109. add_filter('excerpt_more', $more_callback);
  110.  
  111. }
  112.  
  113. $output = get_the_excerpt();
  114.  
  115. $output = apply_filters('wptexturize', $output);
  116.  
  117. $output = apply_filters('convert_chars', $output);
  118.  
  119. $output = '<p>'.$output.'</p>';
  120.  
  121. echo $output;
  122.  
  123. }
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. /* SHORT TITLES *//////////////////////////////////////////////////////////////////
  132.  
  133.  
  134.  
  135. function short_title($after = '', $length) {
  136.  
  137. $mytitle = explode(' ', get_the_title(), $length);
  138.  
  139. if (count($mytitle)>=$length) {
  140.  
  141. array_pop($mytitle);
  142.  
  143. $mytitle = implode(" ",$mytitle). $after;
  144.  
  145. } else {
  146.  
  147. $mytitle = implode(" ",$mytitle);
  148.  
  149. }
  150.  
  151. return $mytitle;
  152.  
  153. }
  154.  
  155.  
  156.  
  157.  
  158.  
  159. /* FEATURED THUMBNAILS *///////////////////////////////////////////////////////////////
  160.  
  161.  
  162.  
  163. if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
  164.  
  165. add_theme_support( 'post-thumbnails' );
  166.  
  167. add_image_size( 'ebuy_thumb', 80, 80, true );
  168.  
  169.  
  170.  
  171. }
  172.  
  173.  
  174.  
  175. /* GET THUMBNAIL URL *////////////////////////////////////////////////////////////////////
  176.  
  177.  
  178.  
  179. function get_image_url(){
  180.  
  181. $image_id = get_post_thumbnail_id();
  182.  
  183. $image_url = wp_get_attachment_image_src($image_id,'large');
  184.  
  185. $image_url = $image_url[0];
  186.  
  187. echo $image_url;
  188.  
  189. }
  190.  
  191.  
  192.  
  193. /* PAGE NAVIGATION */////////////////////////////////////////////////////////////////////
  194.  
  195.  
  196.  
  197.  
  198.  
  199. function getpagenavi(){
  200.  
  201. ?>
  202.  
  203. <div id="navigation">
  204.  
  205. <?php if(function_exists('wp_pagenavi')) : ?>
  206.  
  207. <?php wp_pagenavi() ?>
  208.  
  209. <?php else : ?>
  210.  
  211. <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries','web2feeel')) ?></div>
  212.  
  213. <div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;','web2feel')) ?></div>
  214.  
  215. <div class="clear"></div>
  216.  
  217. <?php endif; ?>
  218.  
  219.  
  220.  
  221. </div>
  222.  
  223.  
  224.  
  225. <?php
  226.  
  227. }
  228.  
  229.  
  230.  
  231. /* BREADCRUMBS *//////////////////////////////////////////////////////////////////////////////
  232.  
  233.  
  234.  
  235. function be_taxonomy_breadcrumb() {
  236.  
  237. // Get the current term
  238.  
  239. $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  240.  
  241. echo '<li><a href="'. get_settings('home') .'"> Home </a> /</li>';
  242.  
  243. // Create a list of all the term's parents
  244.  
  245. $parent = $term->parent;
  246.  
  247. while ($parent):
  248.  
  249. $parents[] = $parent;
  250.  
  251. $new_parent = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
  252.  
  253. $parent = $new_parent->parent;
  254.  
  255. endwhile;
  256.  
  257. if(!empty($parents)):
  258.  
  259. $parents = array_reverse($parents);
  260.  
  261.  
  262.  
  263. // For each parent, create a breadcrumb item
  264.  
  265. foreach ($parents as $parent):
  266.  
  267. $item = get_term_by( 'id', $parent, get_query_var( 'taxonomy' ));
  268.  
  269. $url = get_bloginfo('url').'/'.$item->taxonomy.'/'.$item->slug;
  270.  
  271.  
  272.  
  273. echo '<li><a href="'.$url.'">'.$item->name.'</a> /</li>';
  274.  
  275. endforeach;
  276.  
  277. endif;
  278.  
  279.  
  280.  
  281. // Display the current term in the breadcrumb
  282.  
  283.  
  284.  
  285. echo '<li>'.$term->name.'</li>';
  286.  
  287. }
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297. /* Related Posts *///////////////////////////////////////////////////////////////////////////
  298.  
  299.  
  300.  
  301. function get_posts_related_by_taxonomy($post_id,$taxonomy,$args=array()) {
  302.  
  303. $query = new WP_Query();
  304.  
  305. $do_not_duplicate[] = $post->ID;
  306.  
  307. $terms = wp_get_object_terms($post_id,$taxonomy);
  308.  
  309.  
  310.  
  311. if (count($terms)) {
  312.  
  313. // Assumes only one term for per post in this taxonomy
  314.  
  315. $post_ids = get_objects_in_term($terms[0]->term_id,$taxonomy);
  316.  
  317. $post = get_post($post_id);
  318.  
  319.  
  320.  
  321. $args = wp_parse_args($args,array(
  322.  
  323. 'post_type' => $post->post_type, // The assumes the post types match
  324.  
  325. 'post__in' => $post_ids,
  326.  
  327. 'post__not_in' => array($post->ID),
  328.  
  329. 'taxonomy' => $taxonomy,
  330.  
  331. 'term' => $terms[0]->slug,
  332.  
  333. 'posts_per_page' => 4,
  334.  
  335. )
  336.  
  337.  
  338.  
  339. );
  340.  
  341.  
  342.  
  343. $query = new WP_Query($args);
  344.  
  345. }
  346.  
  347. return $query;
  348.  
  349. }
  350.  
  351.  
  352.  
  353. /* Flush your rewrite rules */////////////////////////////////////////////////////////////////////////
  354.  
  355.  
  356.  
  357. function custom_flush_rewrite_rules() {
  358.  
  359. global $pagenow, $wp_rewrite;
  360.  
  361.  
  362.  
  363. if ( 'themes.php' == $pagenow && isset( $_GET['activated'] ) )
  364.  
  365. $wp_rewrite->flush_rules();
  366.  
  367. }
  368.  
  369.  
  370.  
  371. add_action( 'load-themes.php', 'custom_flush_rewrite_rules' );
  372.  
  373.  
  374.  
  375.  
  376.  
  377. /* Custom Columns */////////////////////////////////////////////////////////////////////////////////////
  378.  
  379.  
  380.  
  381.  
  382.  
  383. // Add to admin_init function
  384.  
  385.  
  386.  
  387. add_filter('manage_edit-goods_columns', 'add_new_goods_columns');
  388.  
  389.  
  390.  
  391. function add_new_goods_columns($movies_columns) {
  392.  
  393. $new_columns['cb'] = '<input type="checkbox" />';
  394.  
  395. $new_columns['title'] = _x('Name', 'column name');
  396.  
  397. $new_columns['thumb'] = __('Thumbnail');
  398.  
  399. $new_columns['product'] = __('Product');
  400.  
  401. $new_columns['cost'] = __('Cost');
  402.  
  403. $new_columns['date'] = _x('Date', 'column name');
  404.  
  405. return $new_columns;
  406.  
  407.  
  408.  
  409. }
  410.  
  411.  
  412.  
  413. add_action('manage_goods_posts_custom_column', 'manage_goods_columns', 10, 2);
  414.  
  415.  
  416.  
  417. function manage_goods_columns($column_name, $id) {
  418.  
  419. global $post;
  420.  
  421. switch ($column_name) {
  422.  
  423. case 'id':
  424.  
  425. echo $id;
  426.  
  427. break;
  428.  
  429.  
  430.  
  431. case 'thumb':
  432.  
  433. echo get_the_post_thumbnail( $post->ID, 'ebuy_thumb' );
  434.  
  435. break;
  436.  
  437.  
  438.  
  439. case 'cost':
  440.  
  441. $duration = get_post_meta( $post->ID, 'wtf_cost', true );
  442.  
  443. echo $duration;
  444.  
  445. break;
  446.  
  447.  
  448.  
  449. case 'product':
  450.  
  451.  
  452.  
  453. $post_type = get_post_type($post_id);
  454.  
  455. $terms = get_the_terms($post_id, 'product');
  456.  
  457. if ( !empty($terms) ) {
  458.  
  459. foreach ( $terms as $term )
  460.  
  461. $post_terms[] = "<a href='edit.php?post_type=goods&product={$term->slug}'> " . esc_html(sanitize_term_field('name', $term->name, $term->term_id, $taxonomy, 'edit')) . "</a>";
  462.  
  463. echo join( ', ', $post_terms );
  464.  
  465. }
  466.  
  467. else echo '<i>No terms.</i>';
  468.  
  469. break;
  470.  
  471. default:
  472.  
  473. break;
  474.  
  475. } // end switch
  476.  
  477. }
  478.  
  479.  
  480.  
  481. /* Admin css *///////////////////////////////////////////////////////////////////
  482.  
  483.  
  484.  
  485. function mytheme_add_init() {
  486.  
  487. $file_dir=get_bloginfo('template_directory');
  488.  
  489. wp_enqueue_style("functions", $file_dir."/lib/guide.css", false, "1.0", "all");
  490.  
  491. }
  492.  
  493. add_action('admin_init', 'mytheme_add_init');
  494.  
  495.  
  496.  
  497. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement