Definition:
function get_theme_data( $theme_file ) {}
Retrieve theme data from parsed theme file.
The description will have the tags filtered with the following HTML elements whitelisted. The ‘a’ element with the <em>href</em> and <em>title</em> attributes. The abbr element with the <em>title</em> attribute. The acronym element with the <em>title</em> attribute allowed. The code, em, and strong elements also allowed.
Parameters
- string $theme_file: Theme file path.
Return values
returns:Theme data.
Source code
function get_theme_data( $theme_file ) { $default_headers = array( 'Name' => 'Theme Name', 'URI' => 'Theme URI', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'Version' => 'Version', 'Template' => 'Template', 'Status' => 'Status', 'Tags' => 'Tags' ); $themes_allowed_tags = array( 'a' => array( 'href' => array(),'title' => array() ), 'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ), 'code' => array(), 'em' => array(), 'strong' => array() ); $theme_data = get_file_data( $theme_file, $default_headers, 'theme' ); $theme_data['Name'] = $theme_data['Title'] = wp_kses( $theme_data['Name'], $themes_allowed_tags ); $theme_data['URI'] = esc_url( $theme_data['URI'] ); $theme_data['Description'] = wptexturize( wp_kses( $theme_data['Description'], $themes_allowed_tags ) ); $theme_data['AuthorURI'] = esc_url( $theme_data['AuthorURI'] ); $theme_data['Template'] = wp_kses( $theme_data['Template'], $themes_allowed_tags ); $theme_data['Version'] = wp_kses( $theme_data['Version'], $themes_allowed_tags ); if ( $theme_data['Status'] == '' ) $theme_data['Status'] = 'publish'; else $theme_data['Status'] = wp_kses( $theme_data['Status'], $themes_allowed_tags ); if ( $theme_data['Tags'] == '' ) $theme_data['Tags'] = array(); else $theme_data['Tags'] = array_map( 'trim', explode( ',', wp_kses( $theme_data['Tags'], array() ) ) ); if ( $theme_data['Author'] == '' ) { $theme_data['Author'] = $theme_data['AuthorName'] = __('Anonymous'); } else { $theme_data['AuthorName'] = wp_kses( $theme_data['Author'], $themes_allowed_tags ); if ( empty( $theme_data['AuthorURI'] ) ) { $theme_data['Author'] = $theme_data['AuthorName']; } else { $theme_data['Author'] = sprintf( '<a href="%1$s" title="%2$s">%3$s</a>', $theme_data['AuthorURI'], esc_attr__( 'Visit author homepage' ), $theme_data['AuthorName'] ); } } return $theme_data; }
1769
No comments yet... Be the first to leave a reply!