ID) . '"> [...]'; } add_filter('excerpt_more', 'hangar_excerpt_more'); // custom login screen i peu de l'admin function custom_login() { echo ''; } add_action('login_head', 'custom_login'); function remove_footer_admin () { echo 'Custom text | Copyright © message'; } add_filter('admin_footer_text', 'remove_footer_admin'); //per imprimir el content sense que ens tregui l'html //https://www.wordpressaddicted.com/wordpress-get-content-with-formatting/ function get_the_content_with_formatting ($more_link_text = '(...)', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); // output max 400 characters $content = substr($content, 0,400); return $content; } // formatting the excertp // https://wordpress.stackexchange.com/a/112651 remove_filter('get_the_excerpt', 'wp_trim_excerpt'); function hangar_html_excerpt($text) { global $post; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace('\]\]\>', ']]>', $text); $text = strip_tags($text, '

'); //write tags allowed $excerpt_length = 55; $words = explode(' ', $text, $excerpt_length + 1); if (count($words)> $excerpt_length) { array_pop($words); array_push($words, '[...]'); $text = implode(' ', $words); } } return $text; } add_filter('get_the_excerpt', 'hangar_html_excerpt'); /** * Filter the except length to 20 words. * https://developer.wordpress.org/reference/functions/the_excerpt/#comment-325 * @param int $length Excerpt length. * @return int (Maybe) modified excerpt length. */ function hangar_custom_excerpt_length( $length ) { return 10; } add_filter( 'excerpt_length', 'hangar_custom_excerpt_length', 999 ); //afegir estils a l'editor /* Custom CSS styles on WYSIWYG - Start ======================================= */ if ( ! function_exists( 'myCustomTinyMCE' ) ) : function myCustomTinyMCE($init) { $init['theme_advanced_buttons2_add_before'] = 'styleselect'; // Adiciona os botões no incio da linha. (theme_advanced_buttons2_add adiciona-os no fim da linha) $init['theme_advanced_styles'] = 'Centrar text=centertext,Text blau=textblau,Lletra petita=petita,Icona PDF=pdficon'; // Especifica os estilos a aplicar pela selectbox acima criada, e que já estão definidos no mycustomstyles.css, altere e/ou acrescente os seus. return $init; } endif; add_filter('tiny_mce_before_init', 'myCustomTinyMCE' ); add_filter( 'mce_css', 'tdav_css' ); // incluir o CSS no tema. function mycustomStyles(){ // time stamp for caching // https://developer.wordpress.org/reference/functions/wp_enqueue_style/#comment-2056 wp_enqueue_style( 'myCustomStyles', get_template_directory_uri() . '/css/styleHangar.css', array(), filemtime(get_template_directory() . '/css/styleHangar.css'), false); } add_action('init', 'myCustomStyles'); /* Custom CSS styles on WYSIWYG - End ======================================= */ /** * Tests if any of a post's assigned categories are descendants of target categories * * @param int|array $cats The target categories. Integer ID or array of integer IDs * @param int|object $_post The post. Omit to test the current post in the Loop or main query * @return bool True if at least 1 of the post's categories is a descendant of any of the target categories * @see get_term_by() You can get a category by name or slug, then pass ID to this function * @uses get_term_children() Passes $cats * @uses in_category() Passes $_post (can be empty) * @version 2.7 * @link http://codex.wordpress.org/Function_Reference/in_category#Testing_if_a_post_is_in_a_descendant_category */ function post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) { // get_term_children() accepts integer ID only $descendants = get_term_children( (int) $cat, 'category'); if ( $descendants && in_category( $descendants, $_post ) ) return true; } return false; } //end function testing descendent categories function is_page_child($post, $idp) { //497 = artistes residents $prova = $post->post_parent; if ($prova == $idp) : return true; else : return false; endif; $idp = null; } //per saber si una categoria té subcategories function has_subcategories($catt) { $child_cats = get_term_children($catt, 'category'); $childs = count($child_cats); if ($childs > 0 ) : return true; else : return false; endif; } // commented on 2022/08/24 moved code to hangar-wp-plugin // //construim un panell de control a l'administració per a que vegin les que estan marcades per a sortir a la home // function menu_control_home(){ // add_menu_page( "Control Home","Control Home", "add_users", "control_home", "control_home", "", 6 ); // } // // function control_home(){ // // global $wpdb; // $querystr = " // SELECT wposts.post_name,wposts.ID, users.user_login, m1.meta_value as inicio, m2.meta_value as orden // FROM $wpdb->posts wposts // INNER JOIN $wpdb->postmeta m1 ON wposts.ID = m1.post_id // INNER JOIN $wpdb->postmeta m2 ON wposts.ID = m2.post_id // INNER JOIN $wpdb->users users ON wposts.post_author = users.ID // WHERE (wposts.post_type = 'post' OR wposts.post_type = 'page') // AND m1.meta_key = 'Inici' // AND m1.meta_value = '1' // AND m2.meta_key = 'Ordre_inici' // GROUP BY ID // ORDER BY inicio DESC, CAST(orden AS SIGNED) ASC // "; // // echo'

//

Control Home


'; // // $pageposts = $wpdb->get_results($querystr, OBJECT); // if ($pageposts): // global $post; // // // echo " // // // // // // // // // // "; // // foreach ($pageposts as $post): // $nom = $post->post_name; // $id = $post->ID; // $autor = $post->user_login; // $inici = $post->inicio; // $ordre = $post->orden; // echo " // // // // // // "; // endforeach; // echo "
Nombre PostIdAutor PostInicioOrden
$nom$id$autor$inici$ordre
"; // endif; // // } // // add_action("admin_menu","menu_control_home"); // Filtre que modifica la funcio que mostra els menús, per poder seleccionar mitjançant el camp title, quines seràn links i quines no. // title= no_link -> no es un link // title != no_link -> es un link // wp_includes -> nav-menu-template.php, es on es trova la clase que s'esta modificant class my_Walker_Nav_Menu extends Walker_Nav_Menu { /** * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param int $current_page Menu item ID. * @param object $args */ function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); $class_names = ' class="' . esc_attr( $class_names ) . '"'; $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . ''; if(! empty( $item->attr_title ) && ($item->attr_title == 'no_link')) { $attributes = ''; } else { $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : ''; } $item_output = $args->before; $item_output .= ''; $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; $item_output .= ''; $item_output .= $args->after; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } } ?> ', ']]>', $text); $allowed_tags = ',,,,

,'; /*** MODIFY THIS. Add the allowed HTML tags separated by a comma.***/ $twopart_tags = ',,,,

,'; /*** MODIFY THIS. Add the twopart HTML tags separated by a comma.***/ /* turn tag list into one big search pattern */ $search_patterns = "/" . str_replace(",","|",str_replace(">", "[^>]*>",$twopart_tags)) . '/'; $text = strip_tags($text, $allowed_tags); $excerpt_word_count = 200; /*** MODIFY THIS. change the excerpt word count to any integer you like.***/ $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); $excerpt_end = ' [...]'; /*** MODIFY THIS. change the excerpt endind to something else.***/ $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if ( count($words) > $excerpt_length ) { array_pop($words); $text = implode(' ', $words); $text = $text . $excerpt_more; } else { $text = implode(' ', $words); }; /* if fragment ends in open tag, trim off */ preg_replace ("/<[^>]*$/", "", $text); /* search for tags in excerpt */ preg_match_all ($search_patterns, $text, $matches); /* if any tags found, check for matching pairs */ $tagstack = array (""); $tagsfound = $matches[0]; while ( count ($tagsfound) > 0) { $tagmatch = array_shift($tagsfound); /* if it's a closing tag, hooray; but if it's not, then look for the closer */ if ( !strpos($tagmatch,"") ) { preg_match("/\pL+/",$tagmatch, $tagwords); $endtag = ""; /* if this tag was not closed, put the closing tag on the stack */ if (!in_array($endtag, $tagsfound) ) { array_push($tagstack,$endtag); }; }; }; /* if any unbalanced tags were found, add the closing tags */ while (count ($tagstack) > 1) { $text = $text . array_pop($tagstack); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); } remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('get_the_excerpt', 'custom_wp_trim_excerpt'); ?>