shortcode_name = 'adminz_breadcrumb'; $___->shortcode_title = 'Breadcrumb'; $___->shortcode_icon = 'text'; $___->options = function () { $_options = []; // $other_plugins = [ // 'type'=> 'select', // 'heading' => 'Use Integrations plugin', // 'default' => '', // 'options' => [ // '' => ADMINZ_NAME, // ], // ]; // if ( class_exists( 'WPSEO_Admin_Init' ) ) { // $other_plugins['options']['wpseo'] = 'Yoast SEO'; // } // if ( class_exists( 'RankMath' ) ) { // $other_plugins['options']['rankmath'] = 'RankMath'; // } // $_options['integrations'] = $other_plugins; $_options['seperator'] = array( 'type' => 'textfield', 'heading' => 'Seperator', 'default' => '/', // 'conditions' => 'integrations == ""', ); $_options['hide_current_item'] = array( 'type' => 'checkbox', 'heading' => 'Hide current_item', 'default' => '', // 'conditions' => 'integrations == ""', ); $_options['post_title_options'] = array( 'type' => 'group', 'heading' => __('Title'), 'options' => array( 'size' => array( 'type' => 'select', 'heading' => 'Font Size', 'default' => '', 'options' => require(get_template_directory() . '/inc/builder/shortcodes/values/sizes.php') ), 'style' => array( 'type' => 'radio-buttons', 'heading' => 'Font Style', 'default' => 'uppercase', 'options' => array( 'normal' => array('title' => 'Abc'), 'uppercase' => array('title' => 'ABC'), ), ), ), ); $_options['advanced_options'] = require(get_template_directory() . '/inc/builder/shortcodes/commons/advanced.php'); return $_options; }; $___->shortcode_callback = function ($atts, $content = null) { // make sure load 1 time if ( isset($GLOBALS['administrator-z']['breadcrumb_exist']) && $GLOBALS['administrator-z']['breadcrumb_exist'] === true ) { return ''; } $GLOBALS['administrator-z']['breadcrumb_exist'] = true; extract(shortcode_atts(array( '_id' => "admz_" . rand(), 'seperator' => '/', 'hide_current_item' => '', 'style' => 'normal', 'size' => '', 'class' => 'adminz_breadcrumb', 'visibility' => '', // 'integrations'=>'' ), $atts)); if (class_exists('RankMath')) { return do_shortcode('[rank_math_breadcrumb] '); } if (class_exists('WPSEO_Admin_Init')) { return do_shortcode('[wpseo_breadcrumb]'); } ob_start(); // Define global $post; $custom_taxonomy = apply_filters('adminz_breadcrumb_custom_taxonomy', ''); // If you have custom taxonomy place it here $classes = 'breadcrumbs'; if ($style) { $classes .= " " . $style; } if ($size) { $classes .= " is-" . $size; } if ($class) { $classes .= " " . $class; } if ($visibility) { $classes .= " " . $visibility; } $defaults = array( 'seperator' => $seperator, 'id' => $_id, 'classes' => $classes, 'home_title' => get_the_title(get_option('page_on_front')), ); $sep = '
  • ' . esc_html($defaults['seperator']) . '
  • '; $position = 1; // Start the breadcrumb with a link to your homepage echo '
    '; echo '
      '; do_action('adminz_breadcrumb_before_items'); // Creating home link echo '
    1. ' . esc_html($defaults['home_title']) . '
    2. ' . apply_filters('the_title', $sep); $position++; if (is_single()) { // Get posts type $post_type = get_post_type(); // If post type is not post if ($post_type != 'post') { $post_type_object = get_post_type_object($post_type); $post_type_link = get_post_type_archive_link($post_type); if ($post_type_object) { echo '
    3. ' . do_shortcode($post_type_object->labels->name) . '
    4. ' . apply_filters('the_title', $sep); } $position++; } // Get categories $category = get_the_category($post->ID); // If category not empty if (!empty($category)) { // Arrange category parent to child $category_values = array_values($category); $get_last_category = end($category_values); // $get_last_category= $category[count($category) - 1]; $get_parent_category = rtrim(get_category_parents($get_last_category->term_id, true, '+'), '+'); $cat_parent = explode('+', $get_parent_category); // Store category in $display_category $display_category = ''; foreach ($cat_parent as $p) { preg_match('#(.*)#', $p, $matches); $display_category .= '
    5. ' . $matches[2] . '
    6. ' . $sep; $position++; } } // If it's a custom post type within a custom taxonomy $taxonomy_exists = taxonomy_exists($custom_taxonomy); if (empty($get_last_category) && !empty($custom_taxonomy) && $taxonomy_exists) { $taxonomy_terms = get_the_terms($post->ID, $custom_taxonomy); $cat_id = $taxonomy_terms[0]->term_id; $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($get_last_category)) { echo do_shortcode($display_category); echo '
    7. ' . get_the_title() . '
    8. '; $position++; } else if (!empty($cat_id)) { echo '
    9. ' . do_shortcode($cat_name) . '
    10. ' . apply_filters('the_title', $sep); $position++; echo '
    11. ' . get_the_title() . '
    12. '; $position++; } else { echo '
    13. ' . get_the_title() . '
    14. '; $position++; } } else if (is_archive()) { if (is_tax()) { // Get posts type $post_type = get_post_type(); // If post type is not post if ($post_type != 'post') { $post_type_object = get_post_type_object($post_type); $post_type_link = get_post_type_archive_link($post_type); if ($post_type_object) { echo '
    15. ' . do_shortcode($post_type_object->labels->name) . '
    16. ' . apply_filters('the_title', $sep); } $position++; } $custom_tax_name = get_queried_object()->name; echo '
    17. ' . do_shortcode($custom_tax_name) . '
    18. '; $position++; } else if (is_category()) { $parent = get_queried_object()->category_parent; if ($parent !== 0) { $parent_category = get_category($parent); $category_link = get_category_link($parent); if ($parent_category) { echo '
    19. ' . do_shortcode($parent_category->name) . '
    20. ' . apply_filters('the_title', $sep); } $position++; } echo '
    21. ' . single_cat_title('', false) . '
    22. '; $position++; } else if (is_tag()) { // Get tag information // $term_id = get_query_var('tag_id'); // $taxonomy = 'post_tag'; // $args = 'include=' . $term_id; // $terms = get_terms($taxonomy, $args); // $get_term_name = $terms[0]->name; $get_term_name = get_queried_object()->name; // Display the tag name echo '
    23. ' . do_shortcode($get_term_name) . '
    24. '; $position++; } else if (is_day()) { // Day archive // Year link echo '
    25. ' . get_the_time('Y') . ' Archives
    26. ' . apply_filters('the_title', $sep); $position++; // Month link echo '
    27. ' . get_the_time('M') . ' Archives
    28. ' . apply_filters('the_title', $sep); $position++; // Day display echo '
    29. ' . get_the_time('jS') . ' ' . get_the_time('M') . ' Archives
    30. '; $position++; } else if (is_month()) { // Month archive // Year link echo '
    31. ' . get_the_time('Y') . ' Archives
    32. ' . apply_filters('the_title', $sep); $position++; // Month Display echo '
    33. ' . get_the_time('M') . ' Archives
    34. '; $position++; } else if (is_year()) { // Year Display echo '
    35. ' . get_the_time('Y') . ' Archives
    36. '; $position++; } else if (is_author()) { // Auhor archive // Get the author information global $author; $userdata = get_userdata($author); // Display author name echo '
    37. ' . 'Author: ' . do_shortcode($userdata->display_name) . '
    38. '; $position++; } else { $post_type_archive_title = post_type_archive_title('', false); if (function_exists('is_shop')) { if (is_shop()) { $post_type_archive_title = get_the_title(get_option('woocommerce_shop_page_id')); } } echo '
    39. ' . $post_type_archive_title . '
    40. '; $position++; } } 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 if (!isset($parents)) $parents = null; foreach ($anc as $ancestor) { $parents .= '
    41. ' . get_the_title($ancestor) . '
    42. ' . $sep; $position++; } // Display parent pages echo do_shortcode($parents); // Current page echo '
    43. ' . get_the_title() . '
    44. '; $position++; } else { // Just display current page if not parents echo '
    45. ' . get_the_title() . '
    46. '; $position++; } } else if (is_search()) { // Search results page echo '
    47. Search results for: ' . get_search_query() . '
    48. '; $position++; } else if (is_404()) { // 404 page echo '
    49. ' . 'Error 404' . '
    50. '; $position++; } else if (is_home()) { echo '
    51. ' . get_the_title(get_option('page_for_posts', true)) . '
    52. '; } echo '
    '; echo '
    '; ?> breadcumnb_exist = true; return ob_get_clean(); }; $___->general_element();