• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Template Export Wordpress Shuriken

Kepala Suku

Web & Mobile Developer
Staff member
#1
\views\export\wp.blade.php
PHP:
@php
$default_author = 'Admin';
$site_url = 'http://example.com/';
$category = isset($argv[2]) ? $argv[2] : 'Uncategorized';
$backdate = isset($argv[1]) ? $argv[1] : date('Y-m-d');
@endphp
{!! '<' . '?' . 'xml version="1.0" encoding="UTF-8"' !!}
<rss version="2.0"
    xmlns:excerpt="http://wordpress.org/export/1.0/excerpt/"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:wp="http://wordpress.org/export/1.0/"
>

<channel>
    <title>My Site</title>
    <link>http://example.com/</link>
    <description></description>
    <pubDate>Thu, 28 May 2009 16:06:40 +0000</pubDate>
    <wp:author><wp:author_id>1</wp:author_id><wp:author_login><![CDATA[staff]]></wp:author_login><wp:author_email><![CDATA[[email protected]]]></wp:author_email><wp:author_display_name><![CDATA[admin]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
    
    <generator>http://wordpress.org/?v=2.7.1</generator>
    <language>id</language>
    <wp:wxr_version>1.0</wp:wxr_version>
    <wp:base_site_url>http://example.com/</wp:base_site_url>
    <wp:base_blog_url>http://example.com/</wp:base_blog_url>

    @foreach($keywords as $post_id => $keyword)
        @php
            $data = get_data(str_slug($keyword));
            $data['keyword'] = $keyword;
            $post_title = $keyword;
            $slug = str_slug( $post_title );
            $unixtime = rand(strtotime($backdate), time());
            $pubdate = date( 'D, d M Y H:i:s', $unixtime )." +0000";
            $post_date = date( 'Y-m-d H:i:s', $unixtime );
            $month = date('m', $unixtime);
            $day = date('d', $unixtime);
            $year = date('Y', $unixtime);

            $post_content = view('export.post', $data, false);
        @endphp
        <item>
            <title><![CDATA[{{ ucwords($keyword) }}]]></title>
            
            <link>{{ $site_url }}{{ $slug }}/</link>
            <pubDate>{{ $pubdate }}</pubDate>

            <dc:creator><![CDATA[{{ $default_author }}]]></dc:creator>
            <wp:postmeta>
                <wp:meta_key>_byline</wp:meta_key>
                <wp:meta_value>{{ $default_author }}</wp:meta_value>
            </wp:postmeta>

            @php
            $category = trim( $category );
            $cat_slug = str_slug( $category );
            @endphp

            <category><![CDATA[{{ $category }}]]></category>
            <category domain="category" nicename="{{ $cat_slug }}"><![CDATA[{{ $category }}]]></category>
            
            @php
                $tags = $data['related'];
            @endphp

            @foreach ( $tags as $tag )
                @if( !empty( $tag ))
                    @php
                    $tag_slug = str_slug( $tag );
                    @endphp

                    <category domain="tag" nicename="{{ $tag_slug }}"><![CDATA[{{ $tag }}]]></category>
                @endif
            @endforeach
            
        
            <guid isPermaLink="false">{{ $site_url }}?p={{ $post_id }}</guid>
            <description></description>
            <content:encoded><![CDATA[{!! $post_content !!}]]></content:encoded>
            <excerpt:encoded><![CDATA[]]></excerpt:encoded>
            <wp:post_id>{{ $post_id }}</wp:post_id>
            <wp:post_date>{{ $post_date }}</wp:post_date>
            <wp:post_date_gmt>{{ $post_date }}</wp:post_date_gmt>
            <wp:comment_status>closed</wp:comment_status>
            <wp:ping_status>closed</wp:ping_status>
            <wp:post_name>{{ $slug }}</wp:post_name>

            <wp:status>publish</wp:status>
            <wp:post_parent>0</wp:post_parent>
            <wp:menu_order>0</wp:menu_order>
            <wp:post_type>post</wp:post_type>
            <wp:post_password></wp:post_password>
            
            <wp:postmeta>
                <wp:meta_key>_old_id</wp:meta_key>
                <wp:meta_value>{{ $post_id }}</wp:meta_value>
            </wp:postmeta>


        </item>
        
    @endforeach

</channel>
</rss>
\views\export\post.blade.php
PHP:
@php
    shuffle($sentences);
@endphp

@if(!empty($sentences))
    <p>{{ @array_pop($sentences) }} {{ @array_pop($sentences) }}</p>
@endif

@foreach(collect($images) as $image)

    <figure style="width: 700px" class="wp-caption alignnone">
        <a href="{{ $image['url'] }}">
        <img title="{{ $image['title'] }}" alt='{{ $image['title'] }}' class="img-fluid" src="{{ $image['url'] }}" width="100%" onerror="this.onerror=null;this.src='https://1.bp.blogspot.com/-MONGJrd9Kcw/XrnP38VN63I/AAAAAAAAAb4/uT1Vpzkd4vwC7ciy8-dtg4R6m_BvkJgcwCEwYBhgL/s1600/7a962f85271b11310d961b24b28148c1.gif';">
        <figcaption class="wp-caption-text">{{ $image['title'] }} | Copyright {{ parse_url($image['source'], PHP_URL_HOST) }}</figcaption>
        </a>
    </figure>

    @if($loop->first)

        <h3>{{ @array_pop($sentences) }}</h3>
        <img src="{{ collect($images)->random()['url'] }}" width="100%" align="left" style="margin-right: 8px;margin-bottom: 8px;"> @foreach(collect($sentences)->chunk(3) as $chunked_sentences)
            <p>
                @if($loop->first) <strong>{{ ucfirst($keyword) }}</strong>. @endif @foreach($chunked_sentences as $chunked_sentence){{ $chunked_sentence }} @endforeach
            </p>
        @endforeach

    @endif

@endforeach