sbstn_becker

functions.php 14072020

Jul 14th, 2020
19
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Exit if accessed directly
  3. if ( !defined( 'ABSPATH' ) ) exit;
  4.  
  5. // BEGIN ENQUEUE PARENT ACTION
  6. // AUTO GENERATED - Do not modify or remove comment markers above or below:
  7.  
  8. if ( !function_exists( 'chld_thm_cfg_locale_css' ) ):
  9. function chld_thm_cfg_locale_css( $uri ){
  10. if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) )
  11. $uri = get_template_directory_uri() . '/rtl.css';
  12. return $uri;
  13. }
  14. endif;
  15. add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' );
  16.  
  17. if ( !function_exists( 'chld_thm_cfg_parent_css' ) ):
  18. function chld_thm_cfg_parent_css() {
  19. wp_enqueue_style( 'chld_thm_cfg_parent', trailingslashit( get_template_directory_uri() ) . 'style.css', array( ) );
  20. }
  21. endif;
  22. add_action( 'wp_enqueue_scripts', 'chld_thm_cfg_parent_css', 10 );
  23.  
  24. add_action('init', function(){
  25. register_taxonomy_for_object_type( 'category', 'page' );
  26. });
  27.  
  28.  
  29. add_action('wp_enqueue_scripts', function() {
  30. if ( is_page()) :
  31. $template = get_post_meta( get_queried_object_id(), '_wp_page_template', true );
  32. if ('child-page.php' == $template ) {
  33. //wp_enqueue_script('masonry-jquery');
  34. }
  35. endif;
  36. });
  37.  
  38.  
  39. // END ENQUEUE PARENT ACTION
  40.  
  41.  
  42.  
  43. /**
  44. * get_more_excerpt()
  45. * Replacement for get_the_content() that always only returns excerpts before
  46. * any <!--more--> tags regardless of context. Otherwise returns all content.
  47. * Must be used in "The Loop".
  48. * WARNING! Password protected posts are not protected with this function.
  49. */
  50. function get_more_excerpt() {
  51. global $post;
  52. $content = $post->post_content;
  53.  
  54. $content = apply_filters('the_content', $content );
  55. // set link text here VVVV
  56. $more_link_text = '(Weiterlesen &hellip;)';
  57. $output = '';
  58. if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches )) {
  59. if ( has_block( 'more', $content ) ) {
  60. // Remove the core/more block delimiters. They will be left over after $content is split up.
  61. $content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content );
  62. }
  63. $content = explode( $matches[0], $content, 2 );
  64. $has_more = true;
  65. } else {
  66. $content = array( $content );
  67. $has_more = false;
  68. }
  69. $output .= $content[0];
  70. if ( $has_more ) {
  71. $output .= ' <a href="' . get_permalink( $post ) . "#more-{$post->ID}\" class=\"more-link\">$more_link_text</a>";
  72. $output = force_balance_tags( $output );
  73. }
  74. return $output;
  75. }
  76.  
  77. // Adds pages to category term requests
  78. add_action( 'pre_get_posts', 'pages_in_cat_list' );
  79. function pages_in_cat_list( $query ) {
  80. if ( ! is_admin() && $query->is_main_query()) {
  81. if ( '' != $query->get('category_name')) {
  82. $query->set( 'post_type', array('post', 'page',));
  83. }
  84. }
  85. }
  86.  
  87.  
  88.  
  89. // Kategorie-Wort ausblenden
  90. function prefix_category_title( $title ) {
  91. if ( is_category() ) {
  92. $title = single_cat_title( '', false );
  93. }
  94. return $title;
  95. }
  96. add_filter( 'get_the_archive_title', 'prefix_category_title' );
  97. //
  98. //
RAW Paste Data