Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Exit if accessed directly
- if ( !defined('ABSPATH')) exit;
- /* I N D E X */
- // ::::::::: DIVI SPECIFIC FUNCTIONS :::::::::::: //
- // ::::::::::::: GENERAL THEME FUNCTIONS ::::::::::::::: //
- //1. ==== FUNCTION Enable WordPress to allow rel=”me” in Google+ profile link === //
- //3. ==== FUNCTION: (Toggle) Custom Excerpt Length/More Filter ==== //
- //4. ==== FUNCTION: Add Author Box Beneath Posts === //
- //5. ==== FUNCTION: Comprehensive Add Breadcrumb Function ==== //
- //6. ==== FUNCTION: Enable Parent Theme's Styleshet ==== //
- //7. ==== FUNCTION: Custom Dashboard Widget ==== //
- //10. ==== FUNCTION: Remove Yahoo, AIM, Jabber User Fields ==== //
- //11. ==== FUNCTION: Twitter & Facebook to Author Profiles ==== //
- //15. ==== FUNCTION: Add Special Top Editing Bar Menu ==== //
- //16. ==== FUNCTION: Enable Post Thumbnails in RSS Feed ==== //
- //20. ==== FUNCTION: Register Custom Post Status
- //23. ==== FUNCTION: Change default avatar image ==== //
- //45. ==== FUNCTION: Add TinyMCE editor to the "Biographical Info" field in a user profile === //
- //50. ==== FUNCTION: Strip Tags from RSS Feeds ---------------- //
- // :::: END Index :::: //
- // ::::::::: DIVI SPECIFIC FUNCTIONS :::::::::::: //
- // ::::::::::::: GENERAL THEME FUNCTIONS ::::::::::::::: //
- //1. ==== FUNCTION Enable WordPress to allow rel=”me” in Google+ profile link === //
- function yoast_allow_rel() {
- global $allowedtags;
- $allowedtags['a']['rel'] = array ();
- }
- add_action( 'wp_loaded', 'yoast_allow_rel' );
- // Add Google Profile field to WordPress User Profile
- function yoast_add_google_profile( $contactmethods ) {
- $contactmethods['google_profile'] = 'Google Profile URL';
- return $contactmethods;
- }
- add_filter( 'user_contactmethods', 'yoast_add_google_profile', 10, 1);
- //3. ==== FUNCTION: Custom Excerpt Length/More Filter ==== //
- //Add Function to Filter Length -- change ID and uncomment all lines below *****//
- //function custom_excerpt_length($length) {
- // Add Condition for Home Page
- //if (is_page('28')) {
- // return 15;
- //}else{
- // return 30;
- //} //Close Condition
- //}
- // Add Filter for Length
- //add_filter('excerpt_length', 'custom_excerpt_length');
- // Add Function to Filter More
- function new_excerpt_more($more) {
- global $post;
- return '<p class="more-link"><a href="'. get_permalink($post->ID) . '">' . 'Read More >>' . '</a></p>';
- }
- //Add Filter for More
- add_filter('excerpt_more', 'new_excerpt_more');
- //4. ==== FUNCTION: Add Author Box Beneath Posts === //
- // SEE: http://www.wpbeginner.com/wp-tutorials/how-to-add-an-author-info-box-in-wordpress-posts/
- function wpb_author_info_box( $content ) {
- global $post;
- // Detect if it is a single post with a post author
- if ( is_single() && isset( $post->post_author ) ) {
- // Get author's display name
- $display_name = get_the_author_meta( 'display_name', $post->post_author );
- // If display name is not available then use nickname as display name
- if ( empty( $display_name ) )
- $display_name = get_the_author_meta( 'nickname', $post->post_author );
- // Get author's biographical information or description
- $user_description = get_the_author_meta( 'user_description', $post->post_author );
- // Get author's website URL
- $user_website = get_the_author_meta('url', $post->post_author);
- // Get link to the author archive page
- $user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author));
- if ( ! empty( $display_name ) )
- $author_details = '<p class="author_name">About ' . $display_name . '</p>';
- if ( ! empty( $user_description ) )
- // Author avatar and bio
- $author_details .= '<p class="author_details">' . nl2br( $user_description ). '</p>';
- $author_details .= '<p class="author_links"><a href="'. $user_posts .'">View all posts by ' . $display_name . '</a>';
- // Check if author has a website in their profile
- if ( ! empty( $user_website ) ) {
- // Display author website link
- $author_details .= ' | <a href="' . $user_website .'" target="_blank" rel="nofollow">Website</a></p>';
- } else {
- // if there is no author website then just close the paragraph
- $author_details .= '</p>';
- }
- // Pass all this info to post content
- $content = $content . '<footer class="author_bio_section" >' . $author_details . '</footer>';
- }
- return $content;
- }
- // Add our function to the post content filter
- add_action( 'the_content', 'wpb_author_info_box' );
- // Allow HTML in author bio section
- remove_filter('pre_user_description', 'wp_filter_kses');
- //5. ==== FUNCTION: Comprehensive Add Breadcrumb Function ==== //
- // --> SEE: https://www.thewebtaylor.com/articles/wordpress-creating-breadcrumbs-without-a-plugin //
- function custom_breadcrumbs() {
- // Settings
- $separator = '>';
- $breadcrums_id = 'breadcrumbs';
- $breadcrums_class = 'breadcrumbs';
- $home_title = 'Homepage';
- // If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
- $custom_taxonomy = 'project_category';
- // Get the query & post information
- global $post,$wp_query;
- // Do not display on the homepage
- if ( !is_front_page() ) {
- // Build the breadcrums
- echo '<ul id="' . $breadcrums_id . '" class="' . $breadcrums_class . '">';
- // Home page
- echo '<li class="item-home"><a class="bread-link bread-home" href="' . get_home_url() . '" title="' . $home_title . '">' . $home_title . '</a></li>';
- echo '<li class="separator separator-home"> ' . $separator . ' </li>';
- if ( is_archive() && !is_tax() && !is_category() && !is_tag() && !is_author() ) {
- echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . post_type_archive_title($prefix, false) . '</strong></li>';
- } else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) {
- // If post is a custom post type
- $post_type = get_post_type();
- // If it is a custom post type display name and link
- if($post_type != 'post') {
- $post_type_object = get_post_type_object($post_type);
- $post_type_archive = get_post_type_archive_link($post_type);
- 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>';
- echo '<li class="separator"> ' . $separator . ' </li>';
- }
- $custom_tax_name = get_queried_object()->name;
- echo '<li class="item-current item-archive"><strong class="bread-current bread-archive">' . $custom_tax_name . '</strong></li>';
- } else if ( is_single() ) {
- // If post is a custom post type
- $post_type = get_post_type('');
- // If it is a custom post type display name and link
- if($post_type != 'post') {
- $post_type_object = get_post_type_object($post_type);
- $post_type_archive = get_post_type_archive_link($post_type);
- 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>';
- echo '<li class="separator"> ' . $separator . ' </li>';
- }
- // Get post category info
- $category = get_the_category();
- if(!empty($category)) {
- // Get last category post is in
- $last_category = end(array_values($category));
- // Get parent any categories and create array
- $get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),',');
- $cat_parents = explode(',',$get_cat_parents);
- // Loop through parent categories and store in variable $cat_display
- $cat_display = '';
- foreach($cat_parents as $parents) {
- $cat_display .= '<li class="item-cat">'.$parents.'</li>';
- $cat_display .= '<li class="separator"> ' . $separator . ' </li>';
- }
- }
- // If it's a custom post type within a custom taxonomy
- $taxonomy_exists = taxonomy_exists($custom_taxonomy);
- if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) {
- $taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy );
- $cat_id = $taxonomy_terms[0]->term_id;
- $cat_nicename = $taxonomy_terms[0]->slug;
- $cat_link = get_term_link($taxonomy_terms[0]->term_id, $custom_taxonomy);
- $cat_name = $taxonomy_terms[0]->name;
- }
- // Check if the post is in a category
- if(!empty($last_category)) {
- echo $cat_display;
- echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
- // Else if post is in a custom taxonomy
- } else if(!empty($cat_id)) {
- 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>';
- echo '<li class="separator"> ' . $separator . ' </li>';
- echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
- } else {
- echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '" title="' . get_the_title() . '">' . get_the_title() . '</strong></li>';
- }
- } else if ( is_category() ) {
- // Category page
- echo '<li class="item-current item-cat"><strong class="bread-current bread-cat">' . single_cat_title('', false) . '</strong></li>';
- } else if ( is_page() ) {
- // Standard page
- if( $post->post_parent ){
- // If child page, get parents
- $anc = get_post_ancestors( $post->ID );
- // Get parents in the right order
- $anc = array_reverse($anc);
- // Parent page loop
- foreach ( $anc as $ancestor ) {
- $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>';
- $parents .= '<li class="separator separator-' . $ancestor . '"> ' . $separator . ' </li>';
- }
- // Display parent pages
- echo $parents;
- // Current page
- echo '<li class="item-current item-' . $post->ID . '"><strong title="' . get_the_title() . '"> ' . get_the_title() . '</strong></li>';
- } else {
- // Just display current page if not parents
- echo '<li class="item-current item-' . $post->ID . '"><strong class="bread-current bread-' . $post->ID . '"> ' . get_the_title() . '</strong></li>';
- }
- } else if ( is_tag() ) {
- // Tag page
- // Get tag information
- $term_id = get_query_var('tag_id');
- $taxonomy = 'post_tag';
- $args = 'include=' . $term_id;
- $terms = get_terms( $taxonomy, $args );
- $get_term_id = $terms[0]->term_id;
- $get_term_slug = $terms[0]->slug;
- $get_term_name = $terms[0]->name;
- // Display the tag name
- 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>';
- } elseif ( is_day() ) {
- // Day archive
- // Year link
- 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>';
- echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
- // Month link
- 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>';
- echo '<li class="separator separator-' . get_the_time('m') . '"> ' . $separator . ' </li>';
- // Day display
- 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>';
- } else if ( is_month() ) {
- // Month Archive
- // Year link
- 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>';
- echo '<li class="separator separator-' . get_the_time('Y') . '"> ' . $separator . ' </li>';
- // Month display
- 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>';
- } else if ( is_year() ) {
- // Display year archive
- 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>';
- } else if ( is_author() ) {
- // Auhor archive
- // Get the author information
- global $author;
- $userdata = get_userdata( $author );
- // Display author name
- 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>';
- } else if ( get_query_var('paged') ) {
- // Paginated archives
- 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>';
- } else if ( is_search() ) {
- // Search results page
- 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>';
- } elseif ( is_404() ) {
- // 404 page
- echo '<li>' . 'Error 404' . '</li>';
- }
- echo '</ul>';
- }
- }
- //6. ==== FUNCTiON: Enqueue Parent Theme Stylesheet
- function my_theme_enqueue_styles() {
- // This will point to style.css in child theme
- wp_enqueue_style( 'my_child_styles', get_stylesheet_directory_uri().'/style.css' );
- // This will point to style.css in the parent theme
- wp_enqueue_style( 'my_parent_styles', get_template_directory_uri().'/style.css' );
- }
- add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
- //7. ==== FUNCTION: Custom Dashboard Widget ==== //
- add_action('wp_dashboard_setup', 'my_custom_dashboard_widgets');
- function my_custom_dashboard_widgets() {
- global $wp_meta_boxes;
- wp_add_dashboard_widget('custom_help_widget', 'CMS Support', 'custom_dashboard_help');
- }
- function custom_dashboard_help() {
- 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>';
- }
- //10. ==== FUNCTION: Remove Yahoo, AIM, Jabber User Fields ==== //
- add_filter('user_contactmethods','hide_profile_fields',10,1);
- function hide_profile_fields( $contactmethods ) {
- unset($contactmethods['aim']);
- unset($contactmethods['jabber']);
- unset($contactmethods['yim']);
- return $contactmethods;
- }
- //11. ==== FUNCTION: Twitter & Facebook to Author Profiles ==== //
- function my_new_contactmethods( $contactmethods ) {
- // Add Twitter
- $contactmethods['twitter'] = 'Twitter Profile URL';
- //add Facebook
- $contactmethods['facebook'] = 'Facebook Profile URL';
- return $contactmethods;
- }
- add_filter('user_contactmethods','my_new_contactmethods',10,1);
- // Then add this code to your loop: | <?php echo $curauth->twitter; (here, close php with ? and greater than >)
- //15. ==== FUNCTION: Add Special Top Editing Bar Menu ==== //
- // http://codex.wordpress.org/Class_Reference/WP_Admin_Bar/add_node
- add_action( 'admin_bar_menu', 'webdx_toolbar_link', 999 );
- function webdx_toolbar_link( $wp_admin_bar ) {
- $args = array(
- 'id' => 'webdx_menu',
- 'title' => 'Webdx Utility',
- 'href' => 'http://webdirexion.com',
- 'meta' => array( 'class' => 'webdx-toolbar' )
- );
- // Add sub menu link to edit categories
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_cats',
- 'title' => __( 'Edit Categories'),
- 'href' => __('/wp-admin/edit-tags.php?taxonomy=category'),
- ));
- // Add sub menu link to edit tags
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_tags',
- 'title' => __( 'Edit Tags'),
- 'href' => __('/edit-tags.php?taxonomy=post_tag'),
- ));
- // Add sub menu link to view all pages
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_pages',
- 'title' => __( 'View All Pages'),
- 'href' => __('/wp-admin/edit.php?post_type=page'),
- ));
- // Add sub menu link to view all posts
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_posts',
- 'title' => __( 'View All Posts'),
- 'href' => __('/wp-admin/edit.php'),
- ));
- // Add sub menu link to view publishing calendar
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_editcal',
- 'title' => __( 'Editing Calendar'),
- 'href' => __('/wp-admin/admin.php?page=nelio-content'),
- ));
- // Add sub menu link to view blocked IPs
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_ipblock',
- 'title' => __( 'Blocked IPs'),
- 'href' => __('/wp-admin/admin.php?page=WordfenceBlockedIPs'),
- ));
- // Add sub menu link to view support tickets
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_supporttic',
- 'title' => __( 'Support Tickets'),
- 'href' => __('/wp-admin/admin.php?page=wpscSupportTickets-admin'),
- ));
- // Add sub menu link to Sitemap
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_engsitemap',
- 'title' => __( 'Sitemap'),
- 'href' => __('/wp-admin/admin.php?page=visual-sitemap'),
- ));
- // Add sub menu link to Monarch Social Settings
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_monarch_social',
- 'title' => __( 'Monarch Social Settings'),
- 'href' => __('/wp-admin/tools.php?page=et_monarch_options#tab_et_social_tab_content_header_stats'),
- ));
- // Add sub menu link to Bloom Popups
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_bloom',
- 'title' => __( 'Bloom Popups'),
- 'href' => __('/wp-admin/admin.php?page=et_bloom_options%2F#tab_et_dashboard_tab_content_header_stats'),
- ));
- // Add sub menu link to Divi Library
- $wp_admin_bar->add_menu( array(
- 'parent' => 'webdx_menu',
- 'id' => 'webdx_divilib',
- 'title' => __( 'Divi Library'),
- 'href' => __('/wp-admin/edit.php?post_type=et_pb_layout'),
- ));
- // Add a new link by copying last section above
- $wp_admin_bar->add_node( $args );
- }
- //16. ==== FUNCTION: Enable Post Thumbnails in RSS Feed ==== //
- add_filter('the_excerpt_rss', 'webendev_featured_to_RSS');
- add_filter('the_content_feed', 'webendev_featured_to_RSS');
- /**
- * Add featured image to RSS feed for use in MailChimp campaign
- *
- */
- function webendev_featured_to_RSS($content) {
- global $post;
- if ( has_post_thumbnail( $post->ID ) ){
- $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;
- }
- return $content;
- }
- //45. ==== FUNCTION: Add TinyMCE editor to the "Biographical Info" field in a user profile === //
- function kpl_user_bio_visual_editor( $user ) {
- // Requires WP 3.3+ and author level capabilities
- if ( function_exists('wp_editor') && current_user_can('publish_posts') ):
- ?>
- <script type="text/javascript">
- (function($){
- // Remove the textarea before displaying visual editor
- $('#description').parents('tr').remove();
- })(jQuery);
- </script>
- <table class="form-table">
- <tr>
- <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
- <td>
- <?php
- $description = get_user_meta( $user->ID, 'description', true);
- wp_editor( $description, 'description' );
- ?>
- <p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p>
- </td>
- </tr>
- </table>
- <?php
- endif;
- }
- add_action('show_user_profile', 'kpl_user_bio_visual_editor');
- add_action('edit_user_profile', 'kpl_user_bio_visual_editor');
- /** Remove textarea filters from description field */
- function kpl_user_bio_visual_editor_unfiltered() {
- remove_all_filters('pre_user_description');
- }
- add_action('admin_init','kpl_user_bio_visual_editor_unfiltered');
- //50. ==== FUNCTION: Strip Tags from RSS Feeds ---------------- //
- function notags_content_rss($content='')
- {
- $content = preg_replace("/\[caption.*\[\/caption\]/", '',$content);
- $content = preg_replace("/\[googlevideo.*\[\/googlevideo\]/", '',$content);
- return $content;
- }
- add_filter('the_content_rss', 'notags_content_rss');
- remove_filter( 'the_content', 'wpautop' );
- // 199. Custom Shortcode testing function
- //
- // // Add Shortcode
- function custom_shortcode($atts) {
- $atts_default = array(
- 'src' => '/wp-content/uploads/2017/08/WebDx-Logo-14-1.png',
- 'class' => 'wp-image',
- 'alt' => 'no alt'
- );
- $atts_merged = shortcode_atts($atts_default, $atts );
- return '<img src="'. $atts_merged['src'] . '" ' . 'class="'. $atts_merged['class'] . '" ' . 'alt="'. $atts_merged['alt'] . '" />';
- }
- add_shortcode( 'imgsrc', 'custom_shortcode' );
- // 200. Custom Shortcode testing function 2
- //
- // // Add Shortcode
- function custom_shortcode_2($atts) {
- if (is_user_logged_in()) {
- $current_user = wp_get_current_user();
- $result = 'Username: ' . $current_user->user_login . '<br />';
- $result .= 'User email: ' . $current_user->user_email . '<br />';
- $result .= 'User first name: ' . $current_user->user_firstname . '<br />';
- return $result;
- } else {
- return 'Nothing to see here2!';
- }
- }
- add_shortcode( 'user-code', 'custom_shortcode_2' );
- // // Add Shortcode
- function custom_shortcode_3($atts) {
- return '<div class="circle" style="background-color:' . $atts['color'] . '"></div>';
- }
- add_shortcode( 'circle', 'custom_shortcode_3' );
- // 201. Custom Post Status Test
- //
- //
- function new_post_status_1(){
- register_post_status( 'publisher_ready', array(
- 'label' => _x( 'Publisher Ready', 'post' ),
- 'public' => true,
- 'exclude_from_search' => false,
- 'show_in_admin_all_list' => true,
- 'show_in_admin_status_list' => true,
- 'label_count' => _n_noop( 'Publisher Ready', 'Publisher Ready' ),
- ) );
- }
- add_action( 'init', 'new_post_status_1' );
- function new_post_status_2(){
- register_post_status( 'editorial_review', array(
- 'label' => _x( 'Editorial Review', 'post' ),
- 'public' => true,
- 'exclude_from_search' => false,
- 'show_in_admin_all_list' => true,
- 'show_in_admin_status_list' => true,
- 'label_count' => _n_noop( 'Editorial Review', 'Editorial Review' ),
- ) );
- }
- add_action( 'init', 'new_post_status_2' );
- function new_post_status_3(){
- register_post_status( 'in_progress', array(
- 'label' => _x( 'In Progress', 'post' ),
- 'public' => true,
- 'exclude_from_search' => false,
- 'show_in_admin_all_list' => true,
- 'show_in_admin_status_list' => true,
- 'label_count' => _n_noop( 'In Progress', 'In Progress' ),
- ) );
- }
- add_action( 'init', 'new_post_status_3' );
- function add_to_post_status_dropdown()
- {
- global $post;
- ?>
- <script>
- jQuery(document).ready(function($){
- $("select#post_status").append("<option value=\"publisher_ready\" <?php selected('publisher_ready', $post->post_status); ?>>Publisher Ready</option>");
- $("select#post_status").append("<option value=\"editorial_review\" <?php selected('editorial_review', $post->post_status); ?>>Editorial Review</option>");
- $("select#post_status").append("<option value=\"in_progress\" <?php selected('in_progress', $post->post_status); ?>>In Progress</option>");
- <?php if ( $post->post_status == 'publisher_ready') { ?>
- $("span#post-status-display").text("Publisher Ready");
- <?php } ?>
- });
- </script>
- <?php
- }
- add_action( 'post_submitbox_misc_actions', 'add_to_post_status_dropdown');
- function add_to_post_status_dropdown_1()
- {
- global $post;
- ?>
- <script>
- jQuery(document).ready(function($){
- <?php if ( $post->post_status == 'editorial_review') { ?>
- $("span#post-status-display").text("Editorial Review");
- <?php } ?>
- });
- </script>
- <?php
- }
- add_action( 'post_submitbox_misc_actions', 'add_to_post_status_dropdown_1');
- function add_to_post_status_dropdown_2()
- {
- global $post;
- ?>
- <script>
- jQuery(document).ready(function($){
- <?php if ( $post->post_status == 'in_progress') { ?>
- $("span#post-status-display").text("In Progress");
- <?php } ?>
- });
- </script>
- <?php
- }
- add_action( 'post_submitbox_misc_actions', 'add_to_post_status_dropdown_2');
- function jc_display_publisher_ready_state( $states ) {
- global $post;
- $arg = get_query_var( 'post_status' );
- if($arg != 'publisher_ready'){
- if($post->post_status == 'publisher_ready'){
- return array('Publisher Ready');
- }
- }
- return $states;
- }
- add_filter( 'display_post_states', 'jc_display_publisher_ready_state' );
- function jc_display_publisher_ready_state_1( $states ) {
- global $post;
- $arg = get_query_var( 'post_status' );
- if($arg != 'in_progress'){
- if($post->post_status == 'in_progress'){
- return array('In Progress');
- }
- }
- return $states;
- }
- add_filter( 'display_post_states', 'jc_display_publisher_ready_state_1' );
- function jc_display_publisher_ready_state_2( $states ) {
- global $post;
- $arg = get_query_var( 'post_status' );
- if($arg != 'editorial_review'){
- if($post->post_status == 'editorial_review'){
- return array('Editorial Review');
- }
- }
- return $states;
- }
- add_filter( 'display_post_states', 'jc_display_publisher_ready_state_2' );
- function et_header_top_hook_example() {
- echo '<a class="et_pb_button header_button" href="#">New Button</a>';
- }
- add_action( 'et_header_top', 'et_header_top_hook_example' );
- function et_before_main_content_hook_example() {?>
- <!-- Example of getting the title and placing it above content -->
- <div class="title-block">
- <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>33test</a>
- </div>
- <style>
- .title-block {
- background: #ed4441;
- padding: 60px 20px;
- text-align: center;
- }
- .title-block a {
- color: #fff;
- font-size: 2em;
- }
- </style>
- <?php
- }
- add_action( 'et_after_main_content', 'et_before_main_content_hook_example');
- add_action( 'woocommerce_before_single_product', 'shortcode_before_entry' );
- function shortcode_before_entry() {
- if(is_product() && get_the_id() == 204671) {
- echo do_shortcode('[content_protector password="password"]');
- }
- }
- add_action( 'woocommerce_after_single_product', 'shortcode_after_entry' );
- function shortcode_after_entry() {
- if(is_product() && get_the_id() == 204671) {
- echo do_shortcode('[/content_protector]');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement