Advertisement
Guest User

Untitled

a guest
Sep 5th, 2018
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 31.16 KB | None | 0 0
  1. <?php
  2. // Exit if accessed directly
  3. if ( !defined('ABSPATH')) exit;
  4.  
  5. /* I N D E X */
  6.  
  7. // ::::::::: DIVI SPECIFIC FUNCTIONS :::::::::::: //
  8.  
  9.  
  10. // ::::::::::::: GENERAL THEME FUNCTIONS ::::::::::::::: //
  11. //1. ==== FUNCTION Enable WordPress to allow rel=”me” in Google+ profile link === //
  12. //3. ==== FUNCTION: (Toggle) Custom Excerpt Length/More Filter ==== //
  13. //4. ==== FUNCTION:  Add Author Box Beneath Posts === //
  14. //5. ==== FUNCTION:  Comprehensive Add Breadcrumb Function ==== //
  15.  
  16. //6. ==== FUNCTION: Enable Parent Theme's Styleshet ==== //
  17.  
  18. //7. ==== FUNCTION:  Custom Dashboard Widget ==== //
  19. //10. ==== FUNCTION:  Remove Yahoo, AIM, Jabber User Fields ==== //
  20. //11. ==== FUNCTION:  Twitter & Facebook to Author Profiles ==== //
  21.  
  22. //15. ====  FUNCTION:  Add Special Top Editing Bar Menu ==== //
  23. //16. ==== FUNCTION:  Enable Post Thumbnails in RSS Feed ==== //
  24.  
  25. //20. ==== FUNCTION: Register Custom Post Status
  26.  
  27.  
  28. //23. ==== FUNCTION:  Change default avatar image ==== //
  29.  
  30. //45. ==== FUNCTION:  Add TinyMCE editor to the "Biographical Info" field in a user profile === //
  31. //50. ==== FUNCTION:  Strip Tags from RSS Feeds ---------------- //
  32.  
  33.  
  34. // :::: END Index :::: //
  35.  
  36.  
  37. // ::::::::: DIVI SPECIFIC FUNCTIONS :::::::::::: //
  38.  
  39.  
  40.  
  41. // ::::::::::::: GENERAL THEME FUNCTIONS ::::::::::::::: //
  42.  
  43. //1. ==== FUNCTION Enable WordPress to allow rel=”me” in Google+ profile link === //
  44. function yoast_allow_rel() {
  45.   global $allowedtags;
  46.   $allowedtags['a']['rel'] = array ();
  47. }
  48. add_action( 'wp_loaded', 'yoast_allow_rel' );
  49.  
  50. // Add Google Profile field to WordPress User Profile
  51. function yoast_add_google_profile( $contactmethods ) {
  52.   $contactmethods['google_profile'] = 'Google Profile URL';
  53.   return $contactmethods;
  54. }
  55. add_filter( 'user_contactmethods', 'yoast_add_google_profile', 10, 1);
  56.  
  57.  
  58.  
  59. //3. ==== FUNCTION:  Custom Excerpt Length/More Filter ==== //
  60.  
  61. //Add Function to Filter Length  -- change ID and uncomment all lines below *****//
  62. //function custom_excerpt_length($length) {
  63. // Add Condition for Home Page
  64. //if (is_page('28')) {
  65. //  return 15;  
  66. //}else{
  67. //  return 30; 
  68. //} //Close Condition
  69. //}
  70. // Add Filter for Length
  71. //add_filter('excerpt_length', 'custom_excerpt_length');
  72.  
  73.  
  74. // Add Function to Filter More
  75. function new_excerpt_more($more) {
  76.        global $post;
  77.     return '<p class="more-link"><a href="'. get_permalink($post->ID) . '">' . 'Read More &gt;&gt;' . '</a></p>';
  78. }
  79.  
  80. //Add Filter for More
  81. add_filter('excerpt_more', 'new_excerpt_more');
  82.  
  83. //4. ==== FUNCTION:  Add Author Box Beneath Posts === //
  84. // SEE:  http://www.wpbeginner.com/wp-tutorials/how-to-add-an-author-info-box-in-wordpress-posts/
  85.  
  86.  
  87. function wpb_author_info_box( $content ) {
  88.  
  89. global $post;
  90.  
  91. // Detect if it is a single post with a post author
  92. if ( is_single() && isset( $post->post_author ) ) {
  93.  
  94. // Get author's display name
  95. $display_name = get_the_author_meta( 'display_name', $post->post_author );
  96.  
  97. // If display name is not available then use nickname as display name
  98. if ( empty( $display_name ) )
  99. $display_name = get_the_author_meta( 'nickname', $post->post_author );
  100.  
  101. // Get author's biographical information or description
  102. $user_description = get_the_author_meta( 'user_description', $post->post_author );
  103.  
  104. // Get author's website URL
  105. $user_website = get_the_author_meta('url', $post->post_author);
  106.  
  107. // Get link to the author archive page
  108. $user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author));
  109.  
  110. if ( ! empty( $display_name ) )
  111.  
  112. $author_details = '<p class="author_name">About ' . $display_name . '</p>';
  113.  
  114. if ( ! empty( $user_description ) )
  115. // Author avatar and bio
  116.  
  117. $author_details .= '<p class="author_details">' . nl2br( $user_description ). '</p>';
  118.  
  119. $author_details .= '<p class="author_links"><a href="'. $user_posts .'">View all posts by ' . $display_name . '</a>';  
  120.  
  121. // Check if author has a website in their profile
  122. if ( ! empty( $user_website ) ) {
  123.  
  124. // Display author website link
  125. $author_details .= ' | <a href="' . $user_website .'" target="_blank" rel="nofollow">Website</a></p>';
  126.  
  127. } else {
  128. // if there is no author website then just close the paragraph
  129. $author_details .= '</p>';
  130. }
  131.  
  132. // Pass all this info to post content  
  133. $content = $content . '<footer class="author_bio_section" >' . $author_details . '</footer>';
  134. }
  135. return $content;
  136. }
  137.  
  138. // Add our function to the post content filter
  139. add_action( 'the_content', 'wpb_author_info_box' );
  140.  
  141. // Allow HTML in author bio section
  142. remove_filter('pre_user_description', 'wp_filter_kses');
  143.  
  144.  
  145. //5. ==== FUNCTION:  Comprehensive Add Breadcrumb Function ==== //
  146. // --> SEE:  https://www.thewebtaylor.com/articles/wordpress-creating-breadcrumbs-without-a-plugin  //
  147.  
  148.  
  149. function custom_breadcrumbs() {
  150.        
  151.     // Settings
  152.     $separator          = '&gt;';
  153.     $breadcrums_id      = 'breadcrumbs';
  154.     $breadcrums_class   = 'breadcrumbs';
  155.     $home_title         = 'Homepage';
  156.      
  157.     // If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
  158.     $custom_taxonomy    = 'project_category';
  159.        
  160.     // Get the query & post information
  161.     global $post,$wp_query;
  162.        
  163.     // Do not display on the homepage
  164.     if ( !is_front_page() ) {
  165.        
  166.         // Build the breadcrums
  167.         echo '<ul id="' . $breadcrums_id . '" class="' . $breadcrums_class . '">';
  168.            
  169.         // Home page
  170.         echo '<li class="item-home"><a class="bread-link bread-home" href="' . get_home_url() . '" title="' . $home_title . '">' . $home_title . '</a></li>';
  171.         echo '<li class="separator separator-home"> ' . $separator . ' </li>';
  172.            
  173.         if ( is_archive() && !is_tax() && !is_category() && !is_tag() && !is_author() ) {
  174.              
  175.             echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . post_type_archive_title($prefix, false) . '</strong></li>';
  176.              
  177.         } else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
  178.              
  179.             // If post is a custom post type
  180.             $post_type = get_post_type();
  181.              
  182.             // If it is a custom post type display name and link
  183.             if($post_type != 'post') {
  184.                  
  185.                 $post_type_object = get_post_type_object($post_type);
  186.                 $post_type_archive = get_post_type_archive_link($post_type);
  187.              
  188.                 echo '<li class="item-cat item-custom-post-type-' . $post_type . '"><a class="bread-cat bread-custom-post-type-' . $post_type . '" href="' . $post_type_archive . '" title="' . $post_type_object->labels->name . '">' . $post_type_object->labels->name . '</a></li>';
  189.                 echo '<li class="separator"> ' . $separator . ' </li>';
  190.              
  191.             }
  192.              
  193.             $custom_tax_name = get_queried_object()->name;
  194.             echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . $custom_tax_name . '</strong></li>';
  195.              
  196.         } else if ( is_single() ) {
  197.              
  198.             // If post is a custom post type
  199.             $post_type = get_post_type('');
  200.              
  201.             // If it is a custom post type display name and link
  202.             if($post_type != 'post') {
  203.                  
  204.                 $post_type_object = get_post_type_object($post_type);
  205.                 $post_type_archive = get_post_type_archive_link($post_type);
  206.              
  207.                 echo '<li class="item-cat item-custom-post-type-' . $post_type . '"><a class="bread-cat bread-custom-post-type-' . $post_type . '" href="' . $post_type_archive . '" title="' . $post_type_object->labels->name . '">' . $post_type_object->labels->name . '</a></li>';
  208.                 echo '<li class="separator"> ' . $separator . ' </li>';
  209.              
  210.             }
  211.            
  212.            
  213.              
  214.             // Get post category info
  215.             $category = get_the_category();
  216.              
  217.             if(!empty($category)) {
  218.              
  219.                 // Get last category post is in
  220.                 $last_category = end(array_values($category));
  221.                  
  222.                 // Get parent any categories and create array
  223.                 $get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),',');
  224.                 $cat_parents = explode(',',$get_cat_parents);
  225.                  
  226.                 // Loop through parent categories and store in variable $cat_display
  227.                 $cat_display = '';
  228.                 foreach($cat_parents as $parents) {
  229.                     $cat_display .= '<li class="item-cat">'.$parents.'</li>';
  230.                     $cat_display .= '<li class="separator"> ' . $separator . ' </li>';
  231.                 }
  232.              
  233.             }
  234.              
  235.             // If it's a custom post type within a custom taxonomy
  236.             $taxonomy_exists = taxonomy_exists($custom_taxonomy);
  237.             if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
  238.                    
  239.                 $taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy );
  240.                 $cat_id         = $taxonomy_terms[0]->term_id;
  241.                 $cat_nicename   = $taxonomy_terms[0]->slug;
  242.                 $cat_link       = get_term_link($taxonomy_terms[0]->term_id, $custom_taxonomy);
  243.                 $cat_name       = $taxonomy_terms[0]->name;
  244.                
  245.             }
  246.              
  247.             // Check if the post is in a category
  248.             if(!empty($last_category)) {
  249.                 echo $cat_display;
  250.                 echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
  251.                  
  252.             // Else if post is in a custom taxonomy
  253.             } else if(!empty($cat_id)) {
  254.                  
  255.                 echo '<li class="item-cat item-cat-' . $cat_id . ' item-cat-' . $cat_nicename . '"><a class="bread-cat bread-cat-' . $cat_id . ' bread-cat-' . $cat_nicename . '" href="' . $cat_link . '" title="' . $cat_name . '">' . $cat_name . '</a></li>';
  256.                 echo '<li class="separator"> ' . $separator . ' </li>';
  257.                 echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
  258.              
  259.             } else {
  260.                  
  261.                 echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
  262.                  
  263.             }
  264.              
  265.         } else if ( is_category() ) {
  266.                
  267.             // Category page
  268.             echo '<li class="item-current item-cat"><strong class="bread-current bread-cat">' . single_cat_title('', false) . '</strong></li>';
  269.                
  270.         } else if ( is_page() ) {
  271.                
  272.             // Standard page
  273.             if( $post->post_parent ){
  274.                    
  275.                 // If child page, get parents
  276.                 $anc = get_post_ancestors( $post->ID );
  277.                    
  278.                 // Get parents in the right order
  279.                 $anc = array_reverse($anc);
  280.                    
  281.                 // Parent page loop
  282.                 foreach ( $anc as $ancestor ) {
  283.                     $parents .= '<li class="item-parent item-parent-' . $ancestor . '"><a class="bread-parent bread-parent-' . $ancestor . '" href="' . get_permalink($ancestor) . '" title="' . get_the_title($ancestor) . '">' . get_the_title($ancestor) . '</a></li>';
  284.                     $parents .= '<li class="separator separator-' . $ancestor . '"> ' . $separator . ' </li>';
  285.                 }
  286.                    
  287.                 // Display parent pages
  288.                 echo $parents;
  289.                    
  290.                 // Current page
  291.                 echo '<li class="item-current item-' . $post->ID . '"><strong title="' . get_the_title() . '"> ' . get_the_title() . '</strong></li>';
  292.                    
  293.             } else {
  294.                    
  295.                 // Just display current page if not parents
  296.                 echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '"> ' . get_the_title() . '</strong></li>';
  297.                    
  298.             }
  299.                
  300.         } else if ( is_tag() ) {
  301.                
  302.             // Tag page
  303.                
  304.             // Get tag information
  305.             $term_id        = get_query_var('tag_id');
  306.             $taxonomy       = 'post_tag';
  307.             $args           = 'include=' . $term_id;
  308.             $terms          = get_terms( $taxonomy, $args );
  309.             $get_term_id    = $terms[0]->term_id;
  310.             $get_term_slug  = $terms[0]->slug;
  311.             $get_term_name  = $terms[0]->name;
  312.                
  313.             // Display the tag name
  314.             echo '<li class="item-current item-tag-' . $get_term_id . ' item-tag-' . $get_term_slug . '"><strong class="bread-current bread-tag-' . $get_term_id . ' bread-tag-' . $get_term_slug . '">' . $get_term_name . '</strong></li>';
  315.            
  316.         } elseif ( is_day() ) {
  317.                
  318.             // Day archive
  319.                
  320.             // Year link
  321.             echo '<li class="item-year item-year-' . get_the_time('Y') . '"><a class="bread-year bread-year-' . get_the_time('Y') . '" href="' . get_year_link( get_the_time('Y') ) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</a></li>';
  322.             echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
  323.                
  324.             // Month link
  325.             echo '<li class="item-month item-month-' . get_the_time('m') . '"><a class="bread-month bread-month-' . get_the_time('m') . '" href="' . get_month_link( get_the_time('Y'), get_the_time('m') ) . '" title="' . get_the_time('M') . '">' . get_the_time('M') . ' Archives</a></li>';
  326.             echo '<li class="separator separator-' . get_the_time('m') . '"> ' . $separator . ' </li>';
  327.                
  328.             // Day display
  329.             echo '<li class="item-current item-' . get_the_time('j') . '"><strong class="bread-current bread-' . get_the_time('j') . '"> ' . get_the_time('jS') . ' ' . get_the_time('M') . ' Archives</strong></li>';
  330.                
  331.         } else if ( is_month() ) {
  332.                
  333.             // Month Archive
  334.                
  335.             // Year link
  336.             echo '<li class="item-year item-year-' . get_the_time('Y') . '"><a class="bread-year bread-year-' . get_the_time('Y') . '" href="' . get_year_link( get_the_time('Y') ) . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</a></li>';
  337.             echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
  338.                
  339.             // Month display
  340.             echo '<li class="item-month item-month-' . get_the_time('m') . '"><strong class="bread-month bread-month-' . get_the_time('m') . '" title="' . get_the_time('M') . '">' . get_the_time('M') . ' Archives</strong></li>';
  341.                
  342.         } else if ( is_year() ) {
  343.                
  344.             // Display year archive
  345.             echo '<li class="item-current item-current-' . get_the_time('Y') . '"><strong class="bread-current bread-current-' . get_the_time('Y') . '" title="' . get_the_time('Y') . '">' . get_the_time('Y') . ' Archives</strong></li>';
  346.                
  347.         } else if ( is_author() ) {
  348.                
  349.             // Auhor archive
  350.                
  351.             // Get the author information
  352.             global $author;
  353.             $userdata = get_userdata( $author );
  354.                
  355.             // Display author name
  356.             echo '<li class="item-current item-current-' . $userdata->user_nicename . '"><strong class="bread-current bread-current-' . $userdata->user_nicename . '" title="' . $userdata->display_name . '">' . 'Author: ' . $userdata->display_name . '</strong></li>';
  357.            
  358.         } else if ( get_query_var('paged') ) {
  359.                
  360.             // Paginated archives
  361.             echo '<li class="item-current item-current-' . get_query_var('paged') . '"><strong class="bread-current bread-current-' . get_query_var('paged') . '" title="Page ' . get_query_var('paged') . '">'.__('Page') . ' ' . get_query_var('paged') . '</strong></li>';
  362.                
  363.         } else if ( is_search() ) {
  364.            
  365.             // Search results page
  366.             echo '<li class="item-current item-current-' . get_search_query() . '"><strong class="bread-current bread-current-' . get_search_query() . '" title="Search results for: ' . get_search_query() . '">Search results for: ' . get_search_query() . '</strong></li>';
  367.            
  368.         } elseif ( is_404() ) {
  369.                
  370.             // 404 page
  371.             echo '<li>' . 'Error 404' . '</li>';
  372.         }
  373.        
  374.         echo '</ul>';
  375.            
  376.     }
  377.        
  378. }
  379.  
  380. //6. ==== FUNCTiON: Enqueue Parent Theme Stylesheet
  381.  
  382.   function my_theme_enqueue_styles() {
  383.         // This will point to style.css in child theme
  384.         wp_enqueue_style( 'my_child_styles', get_stylesheet_directory_uri().'/style.css' );
  385.  
  386.         // This will point to style.css in the parent theme
  387.         wp_enqueue_style( 'my_parent_styles', get_template_directory_uri().'/style.css' );
  388.  
  389. }
  390.  
  391. add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
  392.  
  393.  
  394.  
  395. //7. ==== FUNCTION:  Custom Dashboard Widget ==== //
  396.     add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
  397.  
  398.     function my_custom_dashboard_widgets() {
  399.     global $wp_meta_boxes;
  400.  
  401.     wp_add_dashboard_widget('custom_help_widget', 'CMS Support', 'custom_dashboard_help');
  402.     }
  403.  
  404.     function custom_dashboard_help() {
  405.     echo '<p>Welcome to your CMS! Need <strong>CMS help?</strong> Contact the developer <a href="http://www.webfadds.com">here</a>.</p> <p>For <strong>WordPress Video Tutorials</strong> visit: <a href="http://wordpress.tv/category/how-to/publishing/" target="_blank">Publishing with WordPress Videos.</a></p><p><strong>Hosting support</strong> (emails, disk space, etc.) are provided by your hosting company -- we work with <a href="http://wpsitehosting.com">" World Point Site Hosting - WPsiteHosting.com</a> as a preferred provider, though you may have chosen a different company.</p>';
  406.     }
  407.  
  408.  
  409. //10. ==== FUNCTION:  Remove Yahoo, AIM, Jabber User Fields ==== //
  410.     add_filter('user_contactmethods','hide_profile_fields',10,1);
  411.  
  412.     function hide_profile_fields( $contactmethods ) {
  413.     unset($contactmethods['aim']);
  414.     unset($contactmethods['jabber']);
  415.     unset($contactmethods['yim']);
  416.     return $contactmethods;
  417.     }
  418.  
  419. //11. ==== FUNCTION:  Twitter & Facebook to Author Profiles ==== //
  420.     function my_new_contactmethods( $contactmethods ) {
  421.  
  422.     // Add Twitter
  423.     $contactmethods['twitter'] = 'Twitter Profile URL';
  424.     //add Facebook
  425.     $contactmethods['facebook'] = 'Facebook Profile URL';
  426.  
  427.     return $contactmethods;
  428.     }
  429.     add_filter('user_contactmethods','my_new_contactmethods',10,1);
  430.  
  431. // Then add this code to your loop:  | <?php echo $curauth->twitter; (here, close php with ? and greater than >)
  432.  
  433.  
  434.  
  435. //15. ====  FUNCTION:  Add Special Top Editing Bar Menu ==== //
  436. // http://codex.wordpress.org/Class_Reference/WP_Admin_Bar/add_node
  437.  
  438.  
  439. add_action( 'admin_bar_menu', 'webdx_toolbar_link', 999 );
  440.  
  441. function webdx_toolbar_link( $wp_admin_bar ) {
  442.     $args = array(
  443.         'id'    => 'webdx_menu',
  444.         'title' => 'Webdx Utility',
  445.         'href'  => 'http://webdirexion.com',
  446.         'meta'  => array( 'class' => 'webdx-toolbar' )
  447.     );
  448.    
  449.     // Add sub menu link to edit categories
  450.     $wp_admin_bar->add_menu( array(
  451.         'parent' => 'webdx_menu',
  452.         'id'     => 'webdx_cats',
  453.         'title' => __( 'Edit Categories'),
  454.         'href' => __('/wp-admin/edit-tags.php?taxonomy=category'),
  455.     ));
  456.    
  457.     // Add sub menu link to edit tags
  458.     $wp_admin_bar->add_menu( array(
  459.         'parent' => 'webdx_menu',
  460.         'id'     => 'webdx_tags',
  461.         'title' => __( 'Edit Tags'),
  462.         'href' => __('/edit-tags.php?taxonomy=post_tag'),
  463.     ));
  464.    
  465.     // Add sub menu link to view all pages
  466.     $wp_admin_bar->add_menu( array(
  467.         'parent' => 'webdx_menu',
  468.         'id'     => 'webdx_pages',
  469.         'title' => __( 'View All Pages'),
  470.         'href' => __('/wp-admin/edit.php?post_type=page'),
  471.     ));
  472.    
  473.     // Add sub menu link to view all posts
  474.     $wp_admin_bar->add_menu( array(
  475.         'parent' => 'webdx_menu',
  476.         'id'     => 'webdx_posts',
  477.         'title' => __( 'View All Posts'),
  478.         'href' => __('/wp-admin/edit.php'),
  479.     ));
  480.    
  481.    
  482.     // Add sub menu link to view publishing calendar
  483.     $wp_admin_bar->add_menu( array(
  484.         'parent' => 'webdx_menu',
  485.         'id'     => 'webdx_editcal',
  486.         'title' => __( 'Editing Calendar'),
  487.         'href' => __('/wp-admin/admin.php?page=nelio-content'),
  488.     ));
  489.    
  490.     // Add sub menu link to view blocked IPs
  491.     $wp_admin_bar->add_menu( array(
  492.         'parent' => 'webdx_menu',
  493.         'id'     => 'webdx_ipblock',
  494.         'title' => __( 'Blocked IPs'),
  495.         'href' => __('/wp-admin/admin.php?page=WordfenceBlockedIPs'),
  496.     ));
  497.    
  498.     // Add sub menu link to view support tickets
  499.     $wp_admin_bar->add_menu( array(
  500.         'parent' => 'webdx_menu',
  501.         'id'     => 'webdx_supporttic',
  502.         'title' => __( 'Support Tickets'),
  503.         'href' => __('/wp-admin/admin.php?page=wpscSupportTickets-admin'),
  504.     ));
  505.    
  506.     // Add sub menu link to Sitemap
  507.     $wp_admin_bar->add_menu( array(
  508.         'parent' => 'webdx_menu',
  509.         'id'     => 'webdx_engsitemap',
  510.         'title' => __( 'Sitemap'),
  511.         'href' => __('/wp-admin/admin.php?page=visual-sitemap'),
  512.     ));
  513.    
  514.     // Add sub menu link to Monarch Social Settings
  515.     $wp_admin_bar->add_menu( array(
  516.         'parent' => 'webdx_menu',
  517.         'id'     => 'webdx_monarch_social',
  518.         'title' => __( 'Monarch Social Settings'),
  519.         'href' => __('/wp-admin/tools.php?page=et_monarch_options#tab_et_social_tab_content_header_stats'),
  520.     ));
  521.    
  522.     // Add sub menu link to Bloom Popups
  523.     $wp_admin_bar->add_menu( array(
  524.         'parent' => 'webdx_menu',
  525.         'id'     => 'webdx_bloom',
  526.         'title' => __( 'Bloom Popups'),
  527.         'href' => __('/wp-admin/admin.php?page=et_bloom_options%2F#tab_et_dashboard_tab_content_header_stats'),
  528.     ));
  529.    
  530. // Add sub menu link to Divi Library
  531.     $wp_admin_bar->add_menu( array(
  532.         'parent' => 'webdx_menu',
  533.         'id'     => 'webdx_divilib',
  534.         'title' => __( 'Divi Library'),
  535.         'href' => __('/wp-admin/edit.php?post_type=et_pb_layout'),
  536.     ));
  537.  
  538.    
  539.     // Add a new link by copying last section above
  540.    
  541.     $wp_admin_bar->add_node( $args );
  542. }
  543.  
  544. //16. ==== FUNCTION:  Enable Post Thumbnails in RSS Feed ==== //
  545. add_filter('the_excerpt_rss', 'webendev_featured_to_RSS');
  546. add_filter('the_content_feed', 'webendev_featured_to_RSS');
  547. /**
  548. * Add featured image to RSS feed for use in MailChimp campaign
  549. *
  550. */
  551. function webendev_featured_to_RSS($content) {
  552.     global $post;
  553.  
  554.     if ( has_post_thumbnail( $post->ID ) ){
  555.         $content = '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '" target="_blank">' . get_the_post_thumbnail( $post->ID, 'thumbnail', array( 'style' => 'float:left; margin: 0px 12px 10px 0;' ) ) . '</a>' . $content;
  556.     }
  557.  
  558.     return $content;
  559.  
  560. }
  561.  
  562. //45. ==== FUNCTION:  Add TinyMCE editor to the "Biographical Info" field in a user profile === //
  563.  
  564. function kpl_user_bio_visual_editor( $user ) {
  565.     // Requires WP 3.3+ and author level capabilities
  566.     if ( function_exists('wp_editor') && current_user_can('publish_posts') ):
  567.     ?>
  568.     <script type="text/javascript">
  569.     (function($){
  570.         // Remove the textarea before displaying visual editor
  571.         $('#description').parents('tr').remove();
  572.     })(jQuery);
  573.     </script>
  574.  
  575.     <table class="form-table">
  576.         <tr>
  577.             <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
  578.             <td>
  579.                 <?php
  580.                 $description = get_user_meta( $user->ID, 'description', true);
  581.                 wp_editor( $description, 'description' );
  582.                 ?>
  583.                 <p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p>
  584.             </td>
  585.         </tr>
  586.     </table>
  587.     <?php
  588.     endif;
  589. }
  590. add_action('show_user_profile', 'kpl_user_bio_visual_editor');
  591. add_action('edit_user_profile', 'kpl_user_bio_visual_editor');
  592.  
  593. /**  Remove textarea filters from description field  */
  594. function kpl_user_bio_visual_editor_unfiltered() {
  595.     remove_all_filters('pre_user_description');
  596. }
  597. add_action('admin_init','kpl_user_bio_visual_editor_unfiltered');
  598.  
  599. //50. ==== FUNCTION:  Strip Tags from RSS Feeds ---------------- //
  600. function notags_content_rss($content='')
  601. {
  602. $content = preg_replace("/\[caption.*\[\/caption\]/", '',$content);
  603. $content = preg_replace("/\[googlevideo.*\[\/googlevideo\]/", '',$content);
  604.     return $content;
  605. }
  606. add_filter('the_content_rss', 'notags_content_rss');
  607.  
  608. remove_filter( 'the_content', 'wpautop' );
  609.  
  610. // 199. Custom Shortcode testing function
  611. //
  612. // // Add Shortcode
  613. function custom_shortcode($atts) {
  614.         $atts_default = array(
  615.             'src' => '/wp-content/uploads/2017/08/WebDx-Logo-14-1.png',
  616.             'class' => 'wp-image',
  617.             'alt' => 'no alt'
  618.         );
  619.     $atts_merged = shortcode_atts($atts_default, $atts );
  620.  
  621.     return '<img src="'. $atts_merged['src'] . '" ' . 'class="'. $atts_merged['class'] . '" ' .  'alt="'. $atts_merged['alt'] . '" />';
  622. }
  623.  
  624. add_shortcode( 'imgsrc', 'custom_shortcode' );
  625.  
  626.  
  627. // 200. Custom Shortcode testing function 2
  628. //
  629. // // Add Shortcode
  630. function custom_shortcode_2($atts) {
  631.     if (is_user_logged_in()) {
  632.           $current_user = wp_get_current_user();
  633.  
  634.     $result = 'Username: ' . $current_user->user_login . '<br />';
  635.     $result .= 'User email: ' . $current_user->user_email . '<br />';
  636.     $result .= 'User first name: ' . $current_user->user_firstname . '<br />';
  637.     return $result;
  638.     } else {
  639.         return 'Nothing to see here2!';
  640.     }
  641. }
  642.  
  643. add_shortcode( 'user-code', 'custom_shortcode_2' );
  644.  
  645. // // Add Shortcode
  646. function custom_shortcode_3($atts) {
  647.    
  648.    
  649.     return '<div class="circle" style="background-color:' . $atts['color'] . '"></div>';
  650.  
  651. }
  652.  
  653. add_shortcode( 'circle', 'custom_shortcode_3' );
  654.  
  655. // 201. Custom Post Status Test
  656. //
  657. //  
  658.   function new_post_status_1(){
  659.     register_post_status( 'publisher_ready', array(
  660.         'label'                     => _x( 'Publisher Ready', 'post' ),
  661.         'public'                    => true,
  662.         'exclude_from_search'       => false,
  663.         'show_in_admin_all_list'    => true,
  664.         'show_in_admin_status_list' => true,
  665.         'label_count'               => _n_noop( 'Publisher Ready', 'Publisher Ready' ),
  666.     ) );
  667.      
  668. }
  669. add_action( 'init', 'new_post_status_1' );
  670.  
  671.   function new_post_status_2(){
  672.         register_post_status( 'editorial_review', array(
  673.         'label'                     => _x( 'Editorial Review', 'post' ),
  674.         'public'                    => true,
  675.         'exclude_from_search'       => false,
  676.         'show_in_admin_all_list'    => true,
  677.         'show_in_admin_status_list' => true,
  678.         'label_count'               => _n_noop( 'Editorial Review', 'Editorial Review' ),
  679.     ) );
  680.     }
  681.  
  682. add_action( 'init', 'new_post_status_2' );
  683.  
  684.  function new_post_status_3(){
  685.      
  686.       register_post_status( 'in_progress', array(
  687.         'label'                     => _x( 'In Progress', 'post' ),
  688.         'public'                    => true,
  689.         'exclude_from_search'       => false,
  690.         'show_in_admin_all_list'    => true,
  691.         'show_in_admin_status_list' => true,
  692.         'label_count'               => _n_noop( 'In Progress', 'In Progress' ),
  693.     ) );
  694.  }
  695.  
  696. add_action( 'init', 'new_post_status_3' );
  697.  
  698. function add_to_post_status_dropdown()
  699. {
  700.     global $post;
  701.  
  702.     ?>
  703.     <script>
  704.     jQuery(document).ready(function($){
  705.         $("select#post_status").append("<option value=\"publisher_ready\" <?php selected('publisher_ready', $post->post_status); ?>>Publisher Ready</option>");
  706.         $("select#post_status").append("<option value=\"editorial_review\" <?php selected('editorial_review', $post->post_status); ?>>Editorial Review</option>");
  707.         $("select#post_status").append("<option value=\"in_progress\" <?php selected('in_progress', $post->post_status); ?>>In Progress</option>");
  708.     <?php if ( $post->post_status == 'publisher_ready') { ?>
  709.         $("span#post-status-display").text("Publisher Ready");
  710.     <?php } ?>
  711.        
  712.     });
  713.     </script>
  714.     <?php
  715. }
  716.  
  717. add_action( 'post_submitbox_misc_actions', 'add_to_post_status_dropdown');
  718.  
  719. function add_to_post_status_dropdown_1()
  720. {
  721.     global $post;
  722.  
  723.     ?>
  724.     <script>
  725.     jQuery(document).ready(function($){
  726.  
  727. <?php if ( $post->post_status == 'editorial_review') { ?>
  728.         $("span#post-status-display").text("Editorial Review");
  729.     <?php } ?>
  730.       });
  731.     </script>
  732.     <?php
  733. }
  734.  
  735. add_action( 'post_submitbox_misc_actions', 'add_to_post_status_dropdown_1');
  736.  
  737.  
  738. function add_to_post_status_dropdown_2()
  739. {
  740.     global $post;
  741.  
  742.     ?>
  743.     <script>
  744.     jQuery(document).ready(function($){
  745.        
  746.         <?php if ( $post->post_status == 'in_progress') { ?>
  747.         $("span#post-status-display").text("In Progress");
  748.     <?php } ?>
  749.     });
  750.     </script>
  751.     <?php
  752. }
  753.  
  754. add_action( 'post_submitbox_misc_actions', 'add_to_post_status_dropdown_2');
  755.  
  756. function jc_display_publisher_ready_state( $states ) {
  757.      global $post;
  758.      $arg = get_query_var( 'post_status' );
  759.      if($arg != 'publisher_ready'){
  760.           if($post->post_status == 'publisher_ready'){
  761.                return array('Publisher Ready');
  762.           }
  763.      }
  764.  
  765.     return $states;
  766. }
  767. add_filter( 'display_post_states', 'jc_display_publisher_ready_state' );
  768.  
  769. function jc_display_publisher_ready_state_1( $states ) {
  770.      global $post;
  771.      $arg = get_query_var( 'post_status' );
  772.      if($arg != 'in_progress'){
  773.           if($post->post_status == 'in_progress'){
  774.                return array('In Progress');
  775.           }
  776.      }
  777.  
  778.     return $states;
  779. }
  780. add_filter( 'display_post_states', 'jc_display_publisher_ready_state_1' );
  781.  
  782. function jc_display_publisher_ready_state_2( $states ) {
  783.      global $post;
  784.      $arg = get_query_var( 'post_status' );
  785.      if($arg != 'editorial_review'){
  786.           if($post->post_status == 'editorial_review'){
  787.                return array('Editorial Review');
  788.           }
  789.      }
  790.  
  791.     return $states;
  792. }
  793. add_filter( 'display_post_states', 'jc_display_publisher_ready_state_2' );
  794.  
  795.  
  796.  
  797.  
  798. function et_header_top_hook_example() {
  799.      echo '<a class="et_pb_button header_button" href="#">New Button</a>';
  800.  }
  801.  add_action( 'et_header_top', 'et_header_top_hook_example' );
  802.  
  803.  
  804. function et_before_main_content_hook_example() {?>
  805.  
  806.     <!-- Example of getting the title and placing it above content -->
  807.     <div class="title-block">
  808.     <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>33test</a>
  809.     </div>
  810.    
  811.     <style>
  812.     .title-block {
  813.        background: #ed4441;
  814.        padding: 60px 20px;
  815.        text-align: center;
  816.      }
  817.     .title-block a {
  818.        color: #fff;
  819.        font-size: 2em;
  820.      }
  821.     </style>
  822.     <?php
  823.     }
  824.    
  825. add_action( 'et_after_main_content', 'et_before_main_content_hook_example');
  826.  
  827. add_action( 'woocommerce_before_single_product', 'shortcode_before_entry' );
  828.  
  829.   function shortcode_before_entry() {
  830.  
  831.     if(is_product() && get_the_id() == 204671) {
  832.          echo do_shortcode('[content_protector password="password"]');
  833.     }
  834. }
  835.  
  836. add_action( 'woocommerce_after_single_product', 'shortcode_after_entry' );
  837.  
  838. function shortcode_after_entry() {
  839.  
  840.     if(is_product() && get_the_id() == 204671) {
  841.          echo do_shortcode('[/content_protector]');
  842.     }
  843. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement