_cleanup_header_comment example

$dirname   = pathinfo( $file, PATHINFO_DIRNAME );
    $file_path = $allowed_files[ $file ];

    if ( isset( $wp_file_descriptions[ basename( $file ) ] ) && '.' === $dirname ) {
        return $wp_file_descriptions[ basename( $file ) ];
    } elseif ( file_exists( $file_path ) && is_file( $file_path ) ) {
        $template_data = implode( '', file( $file_path ) );

        if ( preg_match( '|Template Name:(.*)$|mi', $template_data$name ) ) {
            /* translators: %s: Template name. */
            return sprintf( __( '%s Page Template' )_cleanup_header_comment( $name[1] ) );
        }
    }

    return trim( basename( $file ) );
}

/** * Gets the absolute filesystem path to the root of the WordPress installation. * * @since 1.5.0 * * @return string Full filesystem path to the root of the WordPress installation. */
$post_templates = array();

            $files = (array) $this->get_files( 'php', 1, true );

            foreach ( $files as $file => $full_path ) {
                if ( ! preg_match( '|Template Name:(.*)$|mi', file_get_contents( $full_path )$header ) ) {
                    continue;
                }

                $types = array( 'page' );
                if ( preg_match( '|Template Post Type:(.*)$|mi', file_get_contents( $full_path )$type ) ) {
                    $types = explode( ',', _cleanup_header_comment( $type[1] ) );
                }

                foreach ( $types as $type ) {
                    $type = sanitize_key( $type );
                    if ( ! isset( $post_templates[ $type ] ) ) {
                        $post_templates[ $type ] = array();
                    }

                    $post_templates[ $type ][ $file ] = _cleanup_header_comment( $header[1] );
                }
            }

            

    $extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array();
    if ( $extra_headers ) {
        $extra_headers = array_combine( $extra_headers$extra_headers ); // Keys equal values.         $all_headers   = array_merge( $extra_headers(array) $default_headers );
    } else {
        $all_headers = $default_headers;
    }

    foreach ( $all_headers as $field => $regex ) {
        if ( preg_match( '/^(?:[ \t]*<\?php)?[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data$match ) && $match[1] ) {
            $all_headers[ $field ] = _cleanup_header_comment( $match[1] );
        } else {
            $all_headers[ $field ] = '';
        }
    }

    return $all_headers;
}

/** * Returns true. * * Useful for returning true to filters easily. * * @since 3.0.0 * * @see __return_false() * * @return true True. */
Home | Imprint | This part of the site doesn't use cookies.