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 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); $content = substr($content, 0,400); return $content; } //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'
Nombre Post | //Id | //Autor Post | //Inicio | //Orden | //
---|---|---|---|---|
$nom | //$id | //$autor | //$inici | //$ordre | //
,'; /*** 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,"") && !strpos ($tagmatch,"/>") ) {
preg_match("/\pL+/",$tagmatch, $tagwords);
$endtag = "" . $tagwords[0] . ">";
/* 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');
?>