Advertisement
Guest User

Untitled

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