function p2_title_from_content($content) { $title = p2_excerpted_title($content, 30); static $strlen = null; if (!$strlen) { $strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; } $max_len = 30; $title = $strlen($content) > $max_len ? wp_html_excerpt($title, $max_len) . '…' : $title; $title = trim(strip_tags($title)); $title = str_replace("\n", " ", $title); return $title; }
function p2_title_from_content( $content ) { $title = p2_excerpted_title( $content, 8 ); // limit title to 8 full words // Try to detect image or video only posts, and set post title accordingly if ( empty( $title ) ) { if ( preg_match("/<object|<embed/", $content ) ) $title = __( 'Video Post', 'p2' ); elseif ( preg_match( "/<img/", $content ) ) $title = __( 'Image Post', 'p2' ); } return $title; }