Advertisement
Guest User

Untitled

a guest
Feb 26th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 28.24 KB | None | 0 0
  1. <?php
  2.  
  3. /* First we need to extend main profile tabs */
  4.  
  5. add_filter('um_profile_tabs', 'add_custom_profile_tab', 1000 );
  6. function add_custom_profile_tab( $tabs ) {
  7.  
  8.   $tabs['mycustomtab'] = array(
  9.     'name' => 'Your Portfolio',
  10.     'icon' => 'um-faicon-comments',
  11.   );
  12.    
  13.   return $tabs;
  14.    
  15. }
  16.  
  17. function userInvestments() {
  18. // Make the Wordpress database a global:
  19. global $wpdb;
  20. global $current_user;
  21.  
  22. // Get the current user:
  23. get_currentuserinfo();
  24. $userID = $current_user->ID;
  25.  
  26. if( !empty($userID) )
  27. {
  28.     // Run the query to get the Post IDs:
  29.     $results = $wpdb->get_results( "SELECT DISTINCT(post_id) FROM wp_postmeta WHERE meta_key = 'investors_attach' AND meta_value LIKE '%\"$userID\"%'", OBJECT );
  30.    
  31.     // $results now contains an array as follows:
  32.     // [
  33.     //    { post_id: 1 },
  34.     //    { post_id: 2 },
  35.     //    ...
  36.     //    { post_id: 19 },
  37.     // ]
  38.    
  39.     // You will need to output the results as follows:
  40.     foreach( $results as $post )
  41.     {
  42.         echo $post->post_id;
  43.     }
  44. }
  45. }
  46.  
  47.  
  48. /* Then we just have to add content to that tab using this action */
  49.  
  50. add_action('um_profile_content_yourportfolio_default', 'um_profile_content_yourportfolio_default');
  51. function um_profile_content_yourportfolio_default( $args ) {
  52.   echo 'Hello world! - Debugg';
  53. }
  54.  
  55. // Add Translation Option
  56. load_theme_textdomain( 'wpbootstrap', TEMPLATEPATH.'/languages' );
  57. $locale = get_locale();
  58. $locale_file = TEMPLATEPATH . "/languages/$locale.php";
  59. if ( is_readable( $locale_file ) ) require_once( $locale_file );
  60.  
  61. // Clean up the WordPress Head
  62. if( !function_exists( "wp_bootstrap_head_cleanup" ) ) {  
  63.   function wp_bootstrap_head_cleanup() {
  64.     // remove header links
  65.     remove_action( 'wp_head', 'feed_links_extra', 3 );                    // Category Feeds
  66.     remove_action( 'wp_head', 'feed_links', 2 );                          // Post and Comment Feeds
  67.     remove_action( 'wp_head', 'rsd_link' );                               // EditURI link
  68.     remove_action( 'wp_head', 'wlwmanifest_link' );                       // Windows Live Writer
  69.     remove_action( 'wp_head', 'index_rel_link' );                         // index link
  70.     remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );            // previous link
  71.     remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );             // start link
  72.     remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // Links for Adjacent Posts
  73.     remove_action( 'wp_head', 'wp_generator' );                           // WP version
  74.   }
  75. }
  76. // Launch operation cleanup
  77. add_action( 'init', 'wp_bootstrap_head_cleanup' );
  78.  
  79. // remove WP version from RSS
  80. if( !function_exists( "wp_bootstrap_rss_version" ) ) {  
  81.   function wp_bootstrap_rss_version() { return ''; }
  82. }
  83. add_filter( 'the_generator', 'wp_bootstrap_rss_version' );
  84.  
  85. // Remove the […] in a Read More link
  86. if( !function_exists( "wp_bootstrap_excerpt_more" ) ) {  
  87.   function wp_bootstrap_excerpt_more( $more ) {
  88.     global $post;
  89.     return '...  <a href="'. get_permalink($post->ID) . '" class="more-link" title="Read '.get_the_title($post->ID).'">Read more &raquo;</a>';
  90.   }
  91. }
  92. add_filter('excerpt_more', 'wp_bootstrap_excerpt_more');
  93.  
  94. // Add WP 3+ Functions & Theme Support
  95. if( !function_exists( "wp_bootstrap_theme_support" ) ) {  
  96.   function wp_bootstrap_theme_support() {
  97.     add_theme_support( 'post-thumbnails' );      // wp thumbnails (sizes handled in functions.php)
  98.     set_post_thumbnail_size( 125, 125, true );   // default thumb size
  99.     add_theme_support( 'custom-background' );  // wp custom background
  100.     add_theme_support( 'automatic-feed-links' ); // rss
  101.  
  102.     // Add post format support - if these are not needed, comment them out
  103.     add_theme_support( 'post-formats',      // post formats
  104.       array(
  105.         'aside',   // title less blurb
  106.         'gallery', // gallery of images
  107.         'link',    // quick link to other site
  108.         'image',   // an image
  109.         'quote',   // a quick quote
  110.         'status',  // a Facebook like status update
  111.         'video',   // video
  112.         'audio',   // audio
  113.         'chat'     // chat transcript
  114.       )
  115.     );  
  116.  
  117.     add_theme_support( 'menus' );            // wp menus
  118.    
  119.     register_nav_menus(                      // wp3+ menus
  120.       array(
  121.         'main_nav' => 'The Main Menu',   // main nav in header
  122.         'footer_links' => 'Footer Links' // secondary nav in footer
  123.       )
  124.     );  
  125.   }
  126. }
  127. // launching this stuff after theme setup
  128. add_action( 'after_setup_theme','wp_bootstrap_theme_support' );
  129.  
  130. function wp_bootstrap_main_nav() {
  131.   // Display the WordPress menu if available
  132.   wp_nav_menu(
  133.     array(
  134.       'menu' => 'main_nav', /* menu name */
  135.       'menu_class' => 'nav navbar-nav',
  136.       'theme_location' => 'main_nav', /* where in the theme it's assigned */
  137.       'container' => 'false', /* container class */
  138.       'fallback_cb' => 'wp_bootstrap_main_nav_fallback', /* menu fallback */
  139.       'walker' => new Bootstrap_walker()
  140.     )
  141.   );
  142. }
  143.  
  144. function wp_bootstrap_footer_links() {
  145.   // Display the WordPress menu if available
  146.   wp_nav_menu(
  147.     array(
  148.       'menu' => 'footer_links', /* menu name */
  149.       'theme_location' => 'footer_links', /* where in the theme it's assigned */
  150.       'container_class' => 'footer-links clearfix', /* container class */
  151.       'fallback_cb' => 'wp_bootstrap_footer_links_fallback' /* menu fallback */
  152.     )
  153.   );
  154. }
  155.  
  156. // this is the fallback for header menu
  157. function wp_bootstrap_main_nav_fallback() {
  158.   /* you can put a default here if you like */
  159. }
  160.  
  161. // this is the fallback for footer menu
  162. function wp_bootstrap_footer_links_fallback() {
  163.   /* you can put a default here if you like */
  164. }
  165.  
  166. // Shortcodes
  167. require_once('library/shortcodes.php');
  168.  
  169. // Admin Functions (commented out by default)
  170. // require_once('library/admin.php');         // custom admin functions
  171.  
  172. // Custom Backend Footer
  173. add_filter('admin_footer_text', 'wp_bootstrap_custom_admin_footer');
  174. function wp_bootstrap_custom_admin_footer() {
  175.     echo '<span id="footer-thankyou">Developed by <a href="http://320press.com" target="_blank">320press</a></span>. Built using <a href="http://themble.com/bones" target="_blank">Bones</a>.';
  176. }
  177.  
  178. // adding it to the admin area
  179. add_filter('admin_footer_text', 'wp_bootstrap_custom_admin_footer');
  180.  
  181. // Set content width
  182. if ( ! isset( $content_width ) ) $content_width = 580;
  183.  
  184. /************* THUMBNAIL SIZE OPTIONS *************/
  185.  
  186. // Thumbnail sizes
  187. add_image_size( 'wpbs-featured', 780, 300, true );
  188. add_image_size( 'wpbs-featured-home', 970, 311, true);
  189. add_image_size( 'wpbs-featured-carousel', 970, 400, true);
  190.  
  191. /*
  192. to add more sizes, simply copy a line from above
  193. and change the dimensions & name. As long as you
  194. upload a "featured image" as large as the biggest
  195. set width or height, all the other sizes will be
  196. auto-cropped.
  197.  
  198. To call a different size, simply change the text
  199. inside the thumbnail function.
  200.  
  201. For example, to call the 300 x 300 sized image,
  202. we would use the function:
  203. <?php the_post_thumbnail( 'bones-thumb-300' ); ?>
  204. for the 600 x 100 image:
  205. <?php the_post_thumbnail( 'bones-thumb-600' ); ?>
  206.  
  207. You can change the names and dimensions to whatever
  208. you like. Enjoy!
  209. */
  210.  
  211. /************* ACTIVE SIDEBARS ********************/
  212.  
  213. // Sidebars & Widgetizes Areas
  214. function wp_bootstrap_register_sidebars() {
  215.   register_sidebar(array(
  216.     'id' => 'sidebar1',
  217.     'name' => 'Main Sidebar',
  218.     'description' => 'Used on every page BUT the homepage page template.',
  219.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  220.     'after_widget' => '</div>',
  221.     'before_title' => '<h4 class="widgettitle">',
  222.     'after_title' => '</h4>',
  223.   ));
  224.    
  225.   register_sidebar(array(
  226.     'id' => 'sidebar2',
  227.     'name' => 'Homepage Sidebar',
  228.     'description' => 'Used only on the homepage page template.',
  229.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  230.     'after_widget' => '</div>',
  231.     'before_title' => '<h4 class="widgettitle">',
  232.     'after_title' => '</h4>',
  233.   ));
  234.    
  235.   register_sidebar(array(
  236.     'id' => 'footer1',
  237.     'name' => 'Footer 1',
  238.     'before_widget' => '<div id="%1$s" class="widget col-sm-4 %2$s">',
  239.     'after_widget' => '</div>',
  240.     'before_title' => '<h4 class="widgettitle">',
  241.     'after_title' => '</h4>',
  242.   ));
  243.  
  244.   register_sidebar(array(
  245.     'id' => 'footer2',
  246.     'name' => 'Footer 2',
  247.     'before_widget' => '<div id="%1$s" class="widget col-sm-4 %2$s">',
  248.     'after_widget' => '</div>',
  249.     'before_title' => '<h4 class="widgettitle">',
  250.     'after_title' => '</h4>',
  251.   ));
  252.  
  253.   register_sidebar(array(
  254.     'id' => 'footer3',
  255.     'name' => 'Footer 3',
  256.     'before_widget' => '<div id="%1$s" class="widget col-sm-4 %2$s">',
  257.     'after_widget' => '</div>',
  258.     'before_title' => '<h4 class="widgettitle">',
  259.     'after_title' => '</h4>',
  260.   ));
  261.    
  262.    
  263.   /*
  264.   to add more sidebars or widgetized areas, just copy
  265.   and edit the above sidebar code. In order to call
  266.   your new sidebar just use the following code:
  267.  
  268.   Just change the name to whatever your new
  269.   sidebar's id is, for example:
  270.  
  271.   To call the sidebar in your template, you can just copy
  272.   the sidebar.php file and rename it to your sidebar's name.
  273.   So using the above example, it would be:
  274.   sidebar-sidebar2.php
  275.  
  276.   */
  277. } // don't remove this bracket!
  278. add_action( 'widgets_init', 'wp_bootstrap_register_sidebars' );
  279.  
  280. /************* COMMENT LAYOUT *********************/
  281.        
  282. // Comment Layout
  283. function wp_bootstrap_comments($comment, $args, $depth) {
  284.    $GLOBALS['comment'] = $comment; ?>
  285.     <li <?php comment_class(); ?>>
  286.         <article id="comment-<?php comment_ID(); ?>" class="clearfix">
  287.             <div class="comment-author vcard clearfix">
  288.                 <div class="avatar col-sm-3">
  289.                     <?php echo get_avatar( $comment, $size='75' ); ?>
  290.                 </div>
  291.                 <div class="col-sm-9 comment-text">
  292.                     <?php printf('<h4>%s</h4>', get_comment_author_link()) ?>
  293.                     <?php edit_comment_link(__('Edit','wpbootstrap'),'<span class="edit-comment btn btn-sm btn-info"><i class="glyphicon-white glyphicon-pencil"></i>','</span>') ?>
  294.                    
  295.                     <?php if ($comment->comment_approved == '0') : ?>
  296.                         <div class="alert-message success">
  297.                         <p><?php _e('Your comment is awaiting moderation.','wpbootstrap') ?></p>
  298.                         </div>
  299.                     <?php endif; ?>
  300.                    
  301.                     <?php comment_text() ?>
  302.                    
  303.                     <time datetime="<?php echo comment_time('Y-m-j'); ?>"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php comment_time('F jS, Y'); ?> </a></time>
  304.                    
  305.                     <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
  306.                 </div>
  307.             </div>
  308.         </article>
  309.     <!-- </li> is added by wordpress automatically -->
  310. <?php
  311. } // don't remove this bracket!
  312.  
  313. // Display trackbacks/pings callback function
  314. function list_pings($comment, $args, $depth) {
  315.        $GLOBALS['comment'] = $comment;
  316. ?>
  317.         <li id="comment-<?php comment_ID(); ?>"><i class="icon icon-share-alt"></i>&nbsp;<?php comment_author_link(); ?>
  318. <?php
  319.  
  320. }
  321.  
  322. /************* SEARCH FORM LAYOUT *****************/
  323.  
  324. /****************** password protected post form *****/
  325.  
  326. add_filter( 'the_password_form', 'wp_bootstrap_custom_password_form' );
  327.  
  328. function wp_bootstrap_custom_password_form() {
  329.     global $post;
  330.     $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
  331.     $o = '<div class="clearfix"><form class="protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
  332.     ' . '<p>' . __( "This post is password protected. To view it please enter your password below:" ,'wpbootstrap') . '</p>' . '
  333.     <label for="' . $label . '">' . __( "Password:" ,'wpbootstrap') . ' </label><div class="input-append"><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" class="btn btn-primary" value="' . esc_attr__( "Submit",'wpbootstrap' ) . '" /></div>
  334.     </form></div>
  335.     ';
  336.     return $o;
  337. }
  338.  
  339. /*********** update standard wp tag cloud widget so it looks better ************/
  340.  
  341. add_filter( 'widget_tag_cloud_args', 'wp_bootstrap_my_widget_tag_cloud_args' );
  342.  
  343. function wp_bootstrap_my_widget_tag_cloud_args( $args ) {
  344.     $args['number'] = 20; // show less tags
  345.     $args['largest'] = 9.75; // make largest and smallest the same - i don't like the varying font-size look
  346.     $args['smallest'] = 9.75;
  347.     $args['unit'] = 'px';
  348.     return $args;
  349. }
  350.  
  351. // filter tag clould output so that it can be styled by CSS
  352. function wp_bootstrap_add_tag_class( $taglinks ) {
  353.     $tags = explode('</a>', $taglinks);
  354.     $regex = "#(.*tag-link[-])(.*)(' title.*)#e";
  355.  
  356.     foreach( $tags as $tag ) {
  357.         $tagn[] = preg_replace($regex, "('$1$2 label tag-'.get_tag($2)->slug.'$3')", $tag );
  358.     }
  359.  
  360.     $taglinks = implode('</a>', $tagn);
  361.  
  362.     return $taglinks;
  363. }
  364.  
  365. add_action( 'wp_tag_cloud', 'wp_bootstrap_add_tag_class' );
  366.  
  367. add_filter( 'wp_tag_cloud','wp_bootstrap_wp_tag_cloud_filter', 10, 2) ;
  368.  
  369. function wp_bootstrap_wp_tag_cloud_filter( $return, $args )
  370. {
  371.   return '<div id="tag-cloud">' . $return . '</div>';
  372. }
  373.  
  374. // Enable shortcodes in widgets
  375. add_filter( 'widget_text', 'do_shortcode' );
  376.  
  377. // Disable jump in 'read more' link
  378. function wp_bootstrap_remove_more_jump_link( $link ) {
  379.     $offset = strpos($link, '#more-');
  380.     if ( $offset ) {
  381.         $end = strpos( $link, '"',$offset );
  382.     }
  383.     if ( $end ) {
  384.         $link = substr_replace( $link, '', $offset, $end-$offset );
  385.     }
  386.     return $link;
  387. }
  388. add_filter( 'the_content_more_link', 'wp_bootstrap_remove_more_jump_link' );
  389.  
  390. // Remove height/width attributes on images so they can be responsive
  391. add_filter( 'post_thumbnail_html', 'wp_bootstrap_remove_thumbnail_dimensions', 10 );
  392. add_filter( 'image_send_to_editor', 'wp_bootstrap_remove_thumbnail_dimensions', 10 );
  393.  
  394. function wp_bootstrap_remove_thumbnail_dimensions( $html ) {
  395.     $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
  396.     return $html;
  397. }
  398.  
  399. // Add the Meta Box to the homepage template
  400. function wp_bootstrap_add_homepage_meta_box() {  
  401.     global $post;
  402.  
  403.     // Only add homepage meta box if template being used is the homepage template
  404.     // $post_id = isset($_GET['post']) ? $_GET['post'] : (isset($_POST['post_ID']) ? $_POST['post_ID'] : "");
  405.     $post_id = $post->ID;
  406.     $template_file = get_post_meta($post_id,'_wp_page_template',TRUE);
  407.  
  408.     if ( $template_file == 'page-homepage.php' ){
  409.         add_meta_box(  
  410.             'homepage_meta_box', // $id  
  411.             'Optional Homepage Tagline', // $title  
  412.             'wp_bootstrap_show_homepage_meta_box', // $callback  
  413.             'page', // $page  
  414.             'normal', // $context  
  415.             'high'); // $priority  
  416.     }
  417. }
  418.  
  419. add_action( 'add_meta_boxes', 'wp_bootstrap_add_homepage_meta_box' );
  420.  
  421. // Field Array  
  422. $prefix = 'custom_';  
  423. $custom_meta_fields = array(  
  424.     array(  
  425.         'label'=> 'Homepage tagline area',  
  426.         'desc'  => 'Displayed underneath page title. Only used on homepage template. HTML can be used.',  
  427.         'id'    => $prefix.'tagline',  
  428.         'type'  => 'textarea'
  429.     )  
  430. );  
  431.  
  432. // The Homepage Meta Box Callback  
  433. function wp_bootstrap_show_homepage_meta_box() {  
  434.   global $custom_meta_fields, $post;
  435.  
  436.   // Use nonce for verification
  437.   wp_nonce_field( basename( __FILE__ ), 'wpbs_nonce' );
  438.    
  439.   // Begin the field table and loop
  440.   echo '<table class="form-table">';
  441.  
  442.   foreach ( $custom_meta_fields as $field ) {
  443.       // get value of this field if it exists for this post  
  444.       $meta = get_post_meta($post->ID, $field['id'], true);  
  445.       // begin a table row with  
  446.       echo '<tr>
  447.              <th><label for="'.$field['id'].'">'.$field['label'].'</label></th>
  448.              <td>';  
  449.               switch($field['type']) {  
  450.                   // text  
  451.                   case 'text':  
  452.                       echo '<input type="text" name="'.$field['id'].'" id="'.$field['id'].'" value="'.$meta.'" size="60" />
  453.                          <br /><span class="description">'.$field['desc'].'</span>';  
  454.                   break;
  455.                  
  456.                   // textarea  
  457.                   case 'textarea':  
  458.                       echo '<textarea name="'.$field['id'].'" id="'.$field['id'].'" cols="80" rows="4">'.$meta.'</textarea>
  459.                          <br /><span class="description">'.$field['desc'].'</span>';  
  460.                   break;  
  461.               } //end switch  
  462.       echo '</td></tr>';  
  463.   } // end foreach  
  464.   echo '</table>'; // end table  
  465. }  
  466.  
  467. // Save the Data  
  468. function wp_bootstrap_save_homepage_meta( $post_id ) {  
  469.  
  470.     global $custom_meta_fields;  
  471.  
  472.     // verify nonce  
  473.     if ( !isset( $_POST['wpbs_nonce'] ) || !wp_verify_nonce($_POST['wpbs_nonce'], basename(__FILE__)) )  
  474.         return $post_id;
  475.  
  476.     // check autosave
  477.     if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
  478.         return $post_id;
  479.  
  480.     // check permissions
  481.     if ( 'page' == $_POST['post_type'] ) {
  482.         if ( !current_user_can( 'edit_page', $post_id ) )
  483.             return $post_id;
  484.         } elseif ( !current_user_can( 'edit_post', $post_id ) ) {
  485.             return $post_id;
  486.     }
  487.  
  488.     // loop through fields and save the data  
  489.     foreach ( $custom_meta_fields as $field ) {
  490.         $old = get_post_meta( $post_id, $field['id'], true );
  491.         $new = $_POST[$field['id']];
  492.  
  493.         if ($new && $new != $old) {
  494.             update_post_meta( $post_id, $field['id'], $new );
  495.         } elseif ( '' == $new && $old ) {
  496.             delete_post_meta( $post_id, $field['id'], $old );
  497.         }
  498.     } // end foreach
  499. }
  500. add_action( 'save_post', 'wp_bootstrap_save_homepage_meta' );
  501.  
  502. // Add thumbnail class to thumbnail links
  503. function wp_bootstrap_add_class_attachment_link( $html ) {
  504.     $postid = get_the_ID();
  505.     $html = str_replace( '<a','<a class="thumbnail"',$html );
  506.     return $html;
  507. }
  508. add_filter( 'wp_get_attachment_link', 'wp_bootstrap_add_class_attachment_link', 10, 1 );
  509.  
  510. // Add lead class to first paragraph
  511. function wp_bootstrap_first_paragraph( $content ){
  512.     global $post;
  513.  
  514.     // if we're on the homepage, don't add the lead class to the first paragraph of text
  515.     if( is_page_template( 'page-homepage.php' ) )
  516.         return $content;
  517.     else
  518.         return preg_replace('/<p([^>]+)?>/', '<p$1 class="lead">', $content, 1);
  519. }
  520. add_filter( 'the_content', 'wp_bootstrap_first_paragraph' );
  521.  
  522. // Menu output mods
  523. class Bootstrap_walker extends Walker_Nav_Menu{
  524.  
  525.   function start_el(&$output, $object, $depth = 0, $args = Array(), $current_object_id = 0){
  526.  
  527.      global $wp_query;
  528.      $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  529.    
  530.      $class_names = $value = '';
  531.    
  532.         // If the item has children, add the dropdown class for bootstrap
  533.         if ( $args->has_children ) {
  534.             $class_names = "dropdown ";
  535.         }
  536.    
  537.         $classes = empty( $object->classes ) ? array() : (array) $object->classes;
  538.        
  539.         $class_names .= join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $object ) );
  540.         $class_names = ' class="'. esc_attr( $class_names ) . '"';
  541.        
  542.     $output .= $indent . '<li id="menu-item-'. $object->ID . '"' . $value . $class_names .'>';
  543.  
  544.     $attributes  = ! empty( $object->attr_title ) ? ' title="'  . esc_attr( $object->attr_title ) .'"' : '';
  545.     $attributes .= ! empty( $object->target )     ? ' target="' . esc_attr( $object->target     ) .'"' : '';
  546.     $attributes .= ! empty( $object->xfn )        ? ' rel="'    . esc_attr( $object->xfn        ) .'"' : '';
  547.     $attributes .= ! empty( $object->url )        ? ' href="'   . esc_attr( $object->url        ) .'"' : '';
  548.  
  549.     // if the item has children add these two attributes to the anchor tag
  550.     if ( $args->has_children ) {
  551.           $attributes .= ' class="dropdown-toggle" data-toggle="dropdown"';
  552.     }
  553.  
  554.     $item_output = $args->before;
  555.     $item_output .= '<a'. $attributes .'>';
  556.     $item_output .= $args->link_before .apply_filters( 'the_title', $object->title, $object->ID );
  557.     $item_output .= $args->link_after;
  558.  
  559.     // if the item has children add the caret just before closing the anchor tag
  560.     if ( $args->has_children ) {
  561.         $item_output .= '<b class="caret"></b></a>';
  562.     }
  563.     else {
  564.         $item_output .= '</a>';
  565.     }
  566.  
  567.     $item_output .= $args->after;
  568.  
  569.     $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $object, $depth, $args );
  570.   } // end start_el function
  571.        
  572.   function start_lvl(&$output, $depth = 0, $args = Array()) {
  573.     $indent = str_repeat("\t", $depth);
  574.     $output .= "\n$indent<ul class=\"dropdown-menu\">\n";
  575.   }
  576.      
  577.     function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ){
  578.     $id_field = $this->db_fields['id'];
  579.     if ( is_object( $args[0] ) ) {
  580.         $args[0]->has_children = ! empty( $children_elements[$element->$id_field] );
  581.     }
  582.     return parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
  583.   }        
  584. }
  585.  
  586. add_editor_style('editor-style.css');
  587.  
  588. function wp_bootstrap_add_active_class($classes, $item) {
  589.     if( $item->menu_item_parent == 0 && in_array('current-menu-item', $classes) ) {
  590.     $classes[] = "active";
  591.     }
  592.  
  593.   return $classes;
  594. }
  595.  
  596. // Add Twitter Bootstrap's standard 'active' class name to the active nav link item
  597. add_filter('nav_menu_css_class', 'wp_bootstrap_add_active_class', 10, 2 );
  598.  
  599. // enqueue styles
  600. if( !function_exists("wp_bootstrap_theme_styles") ) {  
  601.     function wp_bootstrap_theme_styles() {
  602.         // This is the compiled css file from LESS - this means you compile the LESS file locally and put it in the appropriate directory if you want to make any changes to the master bootstrap.css.
  603.         wp_register_style( 'wpbs', get_template_directory_uri() . '/library/dist/css/styles.f6413c85.min.css', array(), '1.0', 'all' );
  604.         wp_enqueue_style( 'wpbs' );
  605.  
  606.         // For child themes
  607.         wp_register_style( 'wpbs-style', get_stylesheet_directory_uri() . '/style.css', array(), '1.0', 'all' );
  608.         wp_enqueue_style( 'wpbs-style' );
  609.     }
  610. }
  611. add_action( 'wp_enqueue_scripts', 'wp_bootstrap_theme_styles' );
  612.  
  613. // enqueue javascript
  614. if( !function_exists( "wp_bootstrap_theme_js" ) ) {  
  615.   function wp_bootstrap_theme_js(){
  616.  
  617.     if ( !is_admin() ){
  618.       if ( is_singular() AND comments_open() AND ( get_option( 'thread_comments' ) == 1) )
  619.         wp_enqueue_script( 'comment-reply' );
  620.     }
  621.  
  622.     // This is the full Bootstrap js distribution file. If you only use a few components that require the js files consider loading them individually instead
  623.     wp_register_script( 'bootstrap',
  624.       get_template_directory_uri() . '/bower_components/bootstrap/dist/js/bootstrap.js',
  625.       array('jquery'),
  626.       '1.2' );
  627.  
  628.     wp_register_script( 'wpbs-js',
  629.       get_template_directory_uri() . '/library/dist/js/scripts.d1e3d952.min.js',
  630.       array('bootstrap'),
  631.       '1.2' );
  632.  
  633.     wp_register_script( 'modernizr',
  634.       get_template_directory_uri() . '/bower_components/modernizer/modernizr.js',
  635.       array('jquery'),
  636.       '1.2' );
  637.  
  638.     wp_enqueue_script( 'bootstrap' );
  639.     wp_enqueue_script( 'wpbs-js' );
  640.     wp_enqueue_script( 'modernizr' );
  641.    
  642.   }
  643. }
  644. add_action( 'wp_enqueue_scripts', 'wp_bootstrap_theme_js' );
  645.  
  646. // Get <head> <title> to behave like other themes
  647. function wp_bootstrap_wp_title( $title, $sep ) {
  648.   global $paged, $page;
  649.  
  650.   if ( is_feed() ) {
  651.     return $title;
  652.   }
  653.  
  654.   // Add the site name.
  655.   $title .= get_bloginfo( 'name' );
  656.  
  657.   // Add the site description for the home/front page.
  658.   $site_description = get_bloginfo( 'description', 'display' );
  659.   if ( $site_description && ( is_home() || is_front_page() ) ) {
  660.     $title = "$title $sep $site_description";
  661.   }
  662.  
  663.   // Add a page number if necessary.
  664.   if ( $paged >= 2 || $page >= 2 ) {
  665.     $title = "$title $sep " . sprintf( __( 'Page %s', 'wpbootstrap' ), max( $paged, $page ) );
  666.   }
  667.  
  668.   return $title;
  669. }
  670. add_filter( 'wp_title', 'wp_bootstrap_wp_title', 10, 2 );
  671.  
  672. // Related Posts Function (call using wp_bootstrap_related_posts(); )
  673. function wp_bootstrap_related_posts() {
  674.   echo '<ul id="bones-related-posts">';
  675.   global $post;
  676.   $tags = wp_get_post_tags($post->ID);
  677.   if($tags) {
  678.     foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; }
  679.         $args = array(
  680.           'tag' => $tag_arr,
  681.           'numberposts' => 5, /* you can change this to show more */
  682.           'post__not_in' => array($post->ID)
  683.       );
  684.         $related_posts = get_posts($args);
  685.         if($related_posts) {
  686.           foreach ($related_posts as $post) : setup_postdata($post); ?>
  687.               <li class="related_post"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  688.           <?php endforeach; }
  689.       else { ?>
  690.             <li class="no_related_post">No Related Posts Yet!</li>
  691.     <?php }
  692.   }
  693.   wp_reset_query();
  694.   echo '</ul>';
  695. }
  696.  
  697. // Numeric Page Navi (built into the theme by default)
  698. function wp_bootstrap_page_navi($before = '', $after = '') {
  699.   global $wpdb, $wp_query;
  700.   $request = $wp_query->request;
  701.   $posts_per_page = intval(get_query_var('posts_per_page'));
  702.   $paged = intval(get_query_var('paged'));
  703.   $numposts = $wp_query->found_posts;
  704.   $max_page = $wp_query->max_num_pages;
  705.   if ( $numposts <= $posts_per_page ) { return; }
  706.   if(empty($paged) || $paged == 0) {
  707.     $paged = 1;
  708.   }
  709.   $pages_to_show = 7;
  710.   $pages_to_show_minus_1 = $pages_to_show-1;
  711.   $half_page_start = floor($pages_to_show_minus_1/2);
  712.   $half_page_end = ceil($pages_to_show_minus_1/2);
  713.   $start_page = $paged - $half_page_start;
  714.   if($start_page <= 0) {
  715.     $start_page = 1;
  716.   }
  717.   $end_page = $paged + $half_page_end;
  718.   if(($end_page - $start_page) != $pages_to_show_minus_1) {
  719.     $end_page = $start_page + $pages_to_show_minus_1;
  720.   }
  721.   if($end_page > $max_page) {
  722.     $start_page = $max_page - $pages_to_show_minus_1;
  723.     $end_page = $max_page;
  724.   }
  725.   if($start_page <= 0) {
  726.     $start_page = 1;
  727.   }
  728.    
  729.   echo $before.'<ul class="pagination">'."";
  730.   if ($paged > 1) {
  731.     $first_page_text = "&laquo";
  732.     echo '<li class="prev"><a href="'.get_pagenum_link().'" title="' . __('First','wpbootstrap') . '">'.$first_page_text.'</a></li>';
  733.   }
  734.    
  735.   $prevposts = get_previous_posts_link( __('&larr; Previous','wpbootstrap') );
  736.   if($prevposts) { echo '<li>' . $prevposts  . '</li>'; }
  737.   else { echo '<li class="disabled"><a href="#">' . __('&larr; Previous','wpbootstrap') . '</a></li>'; }
  738.  
  739.   for($i = $start_page; $i  <= $end_page; $i++) {
  740.     if($i == $paged) {
  741.       echo '<li class="active"><a href="#">'.$i.'</a></li>';
  742.     } else {
  743.       echo '<li><a href="'.get_pagenum_link($i).'">'.$i.'</a></li>';
  744.     }
  745.   }
  746.   echo '<li class="">';
  747.   next_posts_link( __('Next &rarr;','wpbootstrap') );
  748.   echo '</li>';
  749.   if ($end_page < $max_page) {
  750.     $last_page_text = "&raquo;";
  751.     echo '<li class="next"><a href="'.get_pagenum_link($max_page).'" title="' . __('Last','wpbootstrap') . '">'.$last_page_text.'</a></li>';
  752.   }
  753.   echo '</ul>'.$after."";
  754. }
  755.  
  756. // Remove <p> tags from around images
  757. function wp_bootstrap_filter_ptags_on_images( $content ){
  758.   return preg_replace( '/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content );
  759. }
  760. add_filter( 'the_content', 'wp_bootstrap_filter_ptags_on_images' );
  761.  
  762.  
  763. /* add new tab called "mytab" */
  764.  
  765. add_filter('um_account_page_default_tabs_hook', 'my_portfolio_tab_in_um', 100 );
  766. function my_portfolio_tab_in_um( $tabs ) {
  767.   $tabs[800]['myportfolio']['icon'] = 'um-faicon-pencil';
  768.   $tabs[800]['myportfolio']['title'] = 'My Portfolio';
  769.   $tabs[800]['myportfolio']['custom'] = true;
  770.   return $tabs;
  771. }
  772.  
  773. /* make our new tab hookable */
  774.  
  775. add_action('um_account_tab__myportfolio', 'um_account_tab__myportfolio');
  776. function um_account_tab__myportfolio( $info ) {
  777.   global $ultimatemember;
  778.   extract( $info );
  779.  
  780.   $output = $ultimatemember->account->get_tab_output('myportfolio');
  781.   if ( $output ) { echo $output; }
  782. }
  783.  
  784. /* Finally we add some content in the tab */
  785.  
  786. add_filter('um_account_content_hook_myportfolio', 'um_account_content_hook_myportfolio');
  787. function um_account_content_hook_myportfolio( $output ){
  788.   ob_start();
  789.   ?>
  790.    
  791.   <div class="um-field">
  792.     <h2>My Portfolio</h2> Debug
  793. <h4>Testing, testing..</h4>
  794.   </div>    
  795.    
  796.   <?php
  797.    
  798.   $output .= ob_get_contents();
  799.   ob_end_clean();
  800.   return $output;
  801. }
  802.  
  803.  
  804. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement