2024-01-09 16:13:20 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Functions which enhance the theme by hooking into WordPress
|
|
|
|
*
|
|
|
|
* @package Xarxaprod_theme
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds custom classes to the array of body classes.
|
|
|
|
*
|
|
|
|
* @param array $classes Classes for the body element.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function xarxaprod_body_classes( $classes ) {
|
|
|
|
// Adds a class of hfeed to non-singular pages.
|
|
|
|
if ( ! is_singular() ) {
|
|
|
|
$classes[] = 'hfeed';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Adds a class of no-sidebar when there is no sidebar present.
|
|
|
|
if ( ! is_active_sidebar( 'sidebar-funds' ) ) {
|
|
|
|
$classes[] = 'no-sidebar';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $classes;
|
|
|
|
}
|
|
|
|
add_filter( 'body_class', 'xarxaprod_body_classes' );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a pingback url auto-discovery header for single posts, pages, or attachments.
|
|
|
|
*/
|
|
|
|
function xarxaprod_pingback_header() {
|
|
|
|
if ( is_singular() && pings_open() ) {
|
|
|
|
printf( '<link rel="pingback" href="%s">', esc_url( get_bloginfo( 'pingback_url' ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_action( 'wp_head', 'xarxaprod_pingback_header' );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2024-01-10 12:06:34 +01:00
|
|
|
* Detect if the Xarxaprod "xarxaprod" plugin is active
|
2024-01-09 16:13:20 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
function xarxaprod_plugin_active() {
|
|
|
|
// Detect plugin. For use on Front End only.
|
|
|
|
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
|
|
|
// check for plugin using plugin name
|
2024-01-10 12:06:34 +01:00
|
|
|
if ( is_plugin_active( 'xarxaprod-wp-plugin/xarxaprod-wp-plugin.php' ) ) {
|
2024-01-09 16:13:20 +01:00
|
|
|
//plugin is activated do
|
|
|
|
}
|
|
|
|
//do stuff here
|
|
|
|
} //closing if is_plugin_active
|
|
|
|
|
|
|
|
//add_action( 'wp_head', 'xarxaprod_plugin_active' );
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Echo the post type slug
|
|
|
|
*/
|
|
|
|
function xarxaprod_class_posttype (){
|
|
|
|
if( is_post_type_archive( array('xarxaprod-ajut') )) {
|
|
|
|
echo 'archive-custom-post-type-';
|
|
|
|
printf(get_post_type_object( get_post_type() )->rewrite['slug'] );
|
|
|
|
}
|
|
|
|
}
|
2024-01-13 13:30:18 +01:00
|
|
|
/**
|
|
|
|
* Displays the FAQS subcategories from category id=1
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! function_exists( 'ofisuport_display_faqs_labels' ) ) :
|
|
|
|
function ofisuport_display_faqs_labels() {
|
|
|
|
?>
|
|
|
|
<nav id="tipus-faqs" class="ofisuport-faqs-types">
|
|
|
|
<ul class="ofisuport-label">
|
|
|
|
<?php
|
|
|
|
// https://developer.wordpress.org/reference%2Ffunctions%2Fwp_list_categories%2F/
|
|
|
|
wp_list_categories(
|
|
|
|
array(
|
|
|
|
'child_of' => 1, // category FAQ id=1
|
|
|
|
'hide_empty' => 1,
|
|
|
|
'hide_title_if_empty' => true,
|
|
|
|
'separator' => '<li>',
|
|
|
|
'style' => 'list',
|
|
|
|
'taxonomy' => 'category',
|
|
|
|
'title_li' => '',
|
|
|
|
)
|
|
|
|
); ?>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
endif; //end ofisuport_display_faqs_labels
|
|
|
|
/**
|
|
|
|
* Displays categories for each FAQ
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! function_exists( 'ofisuport_display_each_faq_categories' ) ) :
|
|
|
|
function ofisuport_display_each_faq_categories() {
|
|
|
|
|
|
|
|
$categories = get_the_category();
|
|
|
|
if ( ! empty( $categories ) ) {
|
|
|
|
echo ' <nav id="tipus-faqs" class="ofisuport-faqs-types">';
|
|
|
|
echo ' <ul class="ofisuport-label">';
|
|
|
|
foreach ( $categories as $category ) {
|
|
|
|
if ( ! ($category->cat_ID == '1') ) { //cat_ID '1' is defined as default FAQ
|
|
|
|
echo '<li class="cat-item"><a href="' . esc_url( get_category_link( $category->term_id ) ) . '">' . esc_html( $category->name ) . '</a></li>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo ' </ul>';
|
|
|
|
echo ' </nav>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endif; //end ofisuport_display_each_faq_categories
|
|
|
|
/**
|
|
|
|
* Display search form for FAQs
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! function_exists( 'ofisuport_display_faq_search' ) ) :
|
|
|
|
function ofisuport_display_faqs_search() {
|
|
|
|
// search form for category
|
|
|
|
// https://developer.wordpress.org/reference/functions/get_search_form/#comment-369
|
|
|
|
// https://wordpress.stackexchange.com/questions/313037/restrict-a-search-to-a-custom-post-type
|
|
|
|
?>
|
|
|
|
<form class="ofisuport-search-form" role="search" method="get" action="/">
|
|
|
|
<label class="screen-reader-text" for="search">Search in ajuts</label>
|
|
|
|
<input type="search" id="search" class="search-field" placeholder="cerca faqs..." value="<?php the_search_query();?>" name="s" />
|
|
|
|
<input type="submit" id="searchsubmit" class="search-submit button button-search" value="cerca">
|
|
|
|
<span class="ofisuport-search-submit ofisuport-icon-search"></span>
|
|
|
|
<input type="hidden" value="posts" name="post_type" id="post_type" />
|
|
|
|
<input type="hidden" value="faq" name="category_name" id="category_name" />
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
endif; //end ofisuport_display_each_faq_categories
|