Advertisement
towfiqi

functions.php

Feb 5th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.28 KB | None | 0 0
  1. <?php  
  2.     add_theme_support('automatic-feed-links');
  3.     if ( ! isset( $content_width ) )
  4.     $content_width = 560;
  5.  
  6. //Post Thumbnail   
  7. if(function_exists('add_theme_support')) {
  8.    add_theme_support( 'post-thumbnails' );
  9. }
  10.  
  11. //Register Menus
  12.     register_nav_menus( array(
  13.         'primary' => __( 'Primary Navigation', 'Triton' )
  14.     ) );
  15.  
  16. //SIDEBAR
  17. function trt_widgets_init(){
  18.     register_sidebar(array(
  19.     'name'          => __('Right Sidebar', 'Triton'),
  20.     'id'            => 'sidebar',
  21.     'description'   => __('Right Sidebar', 'Triton'),
  22.     'before_widget' => '<li id="%1$s" class="widget %2$s"><div class="widget_top"></div><div class="widget_wrap">',
  23.     'after_widget'  => '</div><div class="widget_bottom"></div>',
  24.     'before_title'  => '<h3 class="widgettitle">',
  25.     'after_title'   => '</h3>'
  26.     ));
  27.    
  28.     register_sidebar(array(
  29.     'name'          => __('Midrow Widgets', 'Triton'),
  30.     'id'            => 'mid_sidebar',
  31.     'description'   => __('Widget Area for the Midrow', 'Triton'),
  32.     'before_widget' => '<li id="%1$s" class="widget %2$s"><div class="widget_wrap">',
  33.     'after_widget'  => '</div>',
  34.     'before_title'  => '<h3 class="widgettitle">',
  35.     'after_title'   => '</h3>'
  36.     ));
  37.    
  38.     register_sidebar(array(
  39.     'name'          => __('Footer Widgets', 'Triton'),
  40.     'id'            => 'foot_sidebar',
  41.     'description'   => __('Widget Area for the Footer', 'Triton'),
  42.     'before_widget' => '<li id="%1$s" class="widget %2$s"><div class="widget_wrap">',
  43.     'after_widget'  => '</div>',
  44.     'before_title'  => '<h3 class="widgettitle">',
  45.     'after_title'   => '</h3>'
  46.     ));
  47. }
  48.  
  49. add_action( 'widgets_init', 'trt_widgets_init' );
  50.  
  51.  
  52. //Load Java Scripts to header
  53. function trt_head_js() {
  54. if ( !is_admin() ) {
  55. wp_enqueue_script('jquery');
  56. wp_enqueue_script('triton_js',get_template_directory_uri().'/js/triton.js');
  57. wp_enqueue_script('triton_other',get_template_directory_uri().'/js/other.js');
  58. wp_enqueue_script('triton_newslider',get_template_directory_uri().'/js/featureList.js');
  59.  
  60.     $option =  get_option('trt_options');
  61.     if($option['trt_slider']== "Easyslider") {
  62.     wp_enqueue_script('triton_easySlider',get_template_directory_uri().'/js/easyslider.js');
  63.      }
  64.     if($option["trt_diss_fbx"] == "1"){
  65.     } else {
  66.     wp_enqueue_style('triton_fancybox_css',get_template_directory_uri().'/css/fancybox.css');
  67.     wp_enqueue_script('triton_fancybox_js',get_template_directory_uri().'/js/fancybox.js');
  68.     }
  69.  
  70.  
  71.     }
  72. }
  73. add_action('wp_enqueue_scripts', 'trt_head_js');
  74.  
  75.  
  76. add_action('wp_footer', 'trt_load_js');
  77.  
  78. function trt_load_js() { ?>
  79.     <?php $option =  get_option('trt_options'); ?>
  80.     <?php if($option['trt_slider']== "Easyslider") { ?>
  81.     <script type="text/javascript">
  82.         /* <![CDATA[ */
  83.     jQuery(function(){
  84.     jQuery("#slider").easySlider({
  85.         auto: true,
  86.         continuous: true,
  87.         numeric: true,
  88.         pause: <?php echo $option['trt_slider_speed'] ?>
  89.         });
  90.     });
  91.     /* ]]> */
  92.     </script>
  93.     <?php } ?>
  94.  
  95.     <?php }
  96.  
  97. //Add Custom Slider Post
  98. add_action('init', 'trt_slider_register');
  99.  
  100. function trt_slider_register() {
  101.  
  102.     $labels = array(
  103.         'name' => _x('Slider', 'post type general name'),
  104.         'singular_name' => _x('Slider Item', 'post type singular name'),
  105.         'add_new' => _x('Add New', 'Slider item'),
  106.         'add_new_item' => __('Add New Slide', 'Triton'),
  107.         'edit_item' => __('Edit Slides', 'Triton'),
  108.         'new_item' => __('New Slider', 'Triton'),
  109.         'view_item' => __('View Sliders', 'Triton'),
  110.         'search_items' => __('Search Sliders', 'Triton'),
  111.         'menu_icon' => get_stylesheet_directory_uri() . 'images/article16.png',
  112.         'not_found' =>  __('Nothing found', 'Triton'),
  113.         'not_found_in_trash' => __('Nothing found in Trash', 'Triton'),
  114.         'parent_item_colon' => ''
  115.     );
  116.  
  117.     $args = array(
  118.         'labels' => $labels,
  119.         'public' => true,
  120.         'exclude_from_search' => true,
  121.         'publicly_queryable' => true,
  122.         'show_ui' => true,
  123.         'query_var' => true,
  124.         'menu_icon' => get_stylesheet_directory_uri() . '/images/slider_button.png',
  125.         'rewrite' => false,
  126.         'capability_type' => 'post',
  127.         'hierarchical' => false,
  128.         'menu_position' => null,
  129.         'supports' => array('title','excerpt','thumbnail'),
  130.         'register_meta_box_cb' => 'trt_add_meta'
  131.       );
  132.  
  133.     register_post_type( 'slider' , $args );
  134. }
  135. //Slider Link Meta Box
  136. add_action("admin_init", "trt_add_meta");
  137.  
  138. function trt_add_meta(){
  139.   add_meta_box("trt_credits_meta", "Link", "trt_credits_meta", "slider", "normal", "low");
  140. }
  141.  
  142.  
  143. function trt_credits_meta( $post ) {
  144.  
  145.   // Use nonce for verification
  146.   $trtdata = get_post_meta($post->ID, 'trt_slide_link', TRUE);
  147.   wp_nonce_field( 'trt_meta_box_nonce', 'meta_box_nonce' );
  148.  
  149.   // The actual fields for data entry
  150.   echo '<input type="text" id="trt_sldurl" name="trt_sldurl" value="'.$trtdata.'" size="75" />';
  151. }
  152.  
  153. //Save Slider Link Value
  154. add_action('save_post', 'trt_save_details');
  155. function trt_save_details($post_id){
  156.   if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
  157.       return;
  158.  
  159. if( !isset( $_POST['meta_box_nonce'] ) || !wp_verify_nonce( $_POST['meta_box_nonce'], 'trt_meta_box_nonce' ) ) return;
  160.  
  161.   if ( !current_user_can( 'edit_post', $post_id ) )
  162.         return;
  163.  
  164. $trtdata = esc_url( $_POST['trt_sldurl'] );
  165. update_post_meta($post_id, 'trt_slide_link', $trtdata);
  166. return $trtdata;  
  167. }
  168.  
  169.  
  170.  
  171. add_action('do_meta_boxes', 'trt_slider_image_box');
  172.  
  173. function trt_slider_image_box() {
  174.     remove_meta_box( 'postimagediv', 'slider', 'side' );
  175.     add_meta_box('postimagediv', __('Slide Image', 'Triton'), 'post_thumbnail_meta_box', 'slider', 'normal', 'high');
  176. }
  177.  
  178.  
  179. //TRITON get the first image of the post Function
  180. function trt_get_images($overrides = '', $exclude_thumbnail = false)
  181. {
  182.     return get_posts(wp_parse_args($overrides, array(
  183.         'numberposts' => -1,
  184.         'post_parent' => get_the_ID(),
  185.         'post_type' => 'attachment',
  186.         'post_mime_type' => 'image',
  187.         'order' => 'ASC',
  188.         'exclude' => $exclude_thumbnail ? array(get_post_thumbnail_id()) : array(),
  189.         'orderby' => 'menu_order ID'
  190.     )));
  191. }
  192.  
  193.  
  194. //Custom Excerpt Length
  195. function trt_excerptlength_teaser($length) {
  196.     return 33;
  197. }
  198. function trt_excerptlength_index($length) {
  199.     return 12;
  200. }
  201. function trt_excerptmore($more) {
  202.     return '...';
  203. }
  204.  
  205. function trt_excerpt($length_callback='', $more_callback='') {
  206.     global $post;
  207.     if(function_exists($length_callback)){
  208.         add_filter('excerpt_length', $length_callback);
  209.     }
  210.     if(function_exists($more_callback)){
  211.         add_filter('excerpt_more', $more_callback);
  212.     }
  213.     $output = get_the_excerpt();
  214.     $output = apply_filters('wptexturize', $output);
  215.     $output = apply_filters('convert_chars', $output);
  216.     $output = '<p>'.$output.'</p>';
  217.     echo $output;
  218. }
  219.  
  220. //TRITON COMMENTS
  221. function trt_comment($comment, $args, $depth) {
  222.    $GLOBALS['comment'] = $comment; ?>
  223.    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  224.       <div class="comment-body-top"></div>
  225.      <div id="comment-<?php comment_ID(); ?>" class="comment-body">
  226.       <div class="comment-author vcard">
  227.       <div class="avatar"><?php echo get_avatar($comment,$size='58' ); ?></div>
  228.  
  229.          <?php printf(__('<cite class="fn">%s</cite>'), get_comment_author_link()) ?>
  230.       </div>
  231.       <div class="comment-meta commentmetadata">
  232.               <a class="comm_date"><?php printf(get_comment_date()) ?></a>
  233.         <a class="comm_time"><?php printf( get_comment_time()) ?></a>
  234.         </div>
  235.       <?php if ($comment->comment_approved == '0') : ?>
  236.          <em><?php _e('Your comment is awaiting moderation.', 'Triton') ?></em>
  237.          <br />
  238.       <?php endif; ?>
  239.  
  240.       <div class="org_comment"><?php comment_text() ?>
  241.         <div class="comm_meta_reply">
  242.         <div class="comm_reply"><?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?></div>
  243.         <div class='comm_edit'><?php edit_comment_link(__('Edit', 'triton'),'  ','') ?></div></div>
  244.      </div>
  245.      
  246.      </div>
  247. <?php
  248.         }
  249.        
  250. //TRITON TRACKBACKS & PINGS
  251. function trt_ping($comment, $args, $depth) {
  252.  
  253. $GLOBALS['comment'] = $comment; ?>
  254.    
  255.    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
  256.    <div class="comment-body-top"></div>
  257.      <div id="comment-<?php comment_ID(); ?>" class="comment-body">
  258.       <?php if ($comment->comment_approved == '0') : ?>
  259.          <em><?php _e('Your comment is awaiting moderation.', 'Triton') ?></em>
  260.          <br />
  261.       <?php endif; ?>
  262.  
  263.       <div class="org_ping">
  264.         <?php printf(__('<cite class="citeping">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
  265.         <?php comment_text() ?>
  266.             <div class="comment-meta commentmetadata">
  267.             <a class="comm_date"><?php printf(get_comment_date()) ?></a>
  268.             <a class="comm_time"><?php printf( get_comment_time()) ?></a>
  269.             <div class='comm_edit'><?php edit_comment_link(__('Edit', 'triton'),'  ','') ?></div></div>
  270.      </div>
  271.      </div>
  272.      
  273.      
  274. <?php }
  275.  
  276. if (isset($_GET['page']) && $_GET['page'] == 'trt_option') {
  277. add_action('admin_print_scripts', 'trt_admin_scripts');
  278. add_action('admin_print_styles', 'trt_admin_styles');
  279. }
  280.  
  281.  
  282. include(TEMPLATEPATH . '/lib/script/pagination.php');
  283. include(TEMPLATEPATH . '/lib/includes/shortcodes.php');
  284. include(TEMPLATEPATH . '/lib/includes/widgets.php');
  285. include(TEMPLATEPATH . '/lib/includes/control_panel.php');
  286. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement