403Webshell
Server IP : 38.190.208.107  /  Your IP : 216.73.217.1
Web Server : nginx/1.28.1
System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64
User : root ( 0)
PHP Version : 8.2.28
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /www/wwwroot/wp.10/wp-content/plugins/clarity-seo/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/wwwroot/wp.10/wp-content/plugins/clarity-seo/includes/sitemap.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

// Generate dynamic sitemap.xml
function clarity_seo_generate_sitemap() {
    if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
        return;
    }

    $request_uri = sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) );

    if ( strpos( $request_uri, '/sitemap.xml' ) === false ) {
        return;
    }

    header( 'Content-Type: application/xml; charset=UTF-8' );
    echo '<?xml version="1.0" encoding="UTF-8"?' . ">\n";
    ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
        xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
        xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
    <?php

    // === Posts & Pages ===
    $post_types = get_post_types( [ 'public' => true ], 'names' );
    unset( $post_types['attachment'] );

    $pages = get_posts( [
        'post_type'      => array_values( $post_types ),
        'post_status'    => 'publish',
        'numberposts'    => -1,
        'orderby'        => 'modified',
        'order'          => 'DESC',
    ] );

    foreach ( $pages as $page ) {
        $permalink   = get_permalink( $page->ID );
        $lastmod     = get_the_modified_date( 'c', $page->ID );
        $priority    = ( $page->ID == get_option( 'page_on_front' ) ) ? '1.0' : ( $page->post_type === 'product' ? '0.7' : '0.8' );
        $changefreq  = ( $page->post_type === 'post' ) ? 'daily' : ( $page->post_type === 'product' ? 'weekly' : 'monthly' );

        $og_image = get_post_meta( $page->ID, '_clarity_seo_og_image', true );
        if ( ! $og_image && has_post_thumbnail( $page->ID ) ) {
            $og_image = wp_get_attachment_url( get_post_thumbnail_id( $page->ID ) );
        }
        ?>
    <url>
        <loc><?php echo esc_url( $permalink ); ?></loc>
        <lastmod><?php echo esc_attr( $lastmod ); ?></lastmod>
        <changefreq><?php echo esc_attr( $changefreq ); ?></changefreq>
        <priority><?php echo esc_attr( $priority ); ?></priority>
        <?php if ( $og_image ) : ?>
        <image:image>
            <image:loc><?php echo esc_url( $og_image ); ?></image:loc>
            <image:title><?php echo esc_attr( get_the_title( $page->ID ) ); ?></image:title>
        </image:image>
        <?php endif; ?>
        <?php if ( has_block( 'video', $page->post_content ) && $og_image ) : ?>
        <video:video>
            <video:thumbnail_loc><?php echo esc_url( $og_image ); ?></video:thumbnail_loc>
            <video:title><?php echo esc_attr( get_the_title( $page->ID ) ); ?></video:title>
            <video:description><?php echo esc_attr( wp_trim_words( $page->post_excerpt, 20 ) ); ?></video:description>
        </video:video>
        <?php endif; ?>
        <?php if ( $page->post_type === 'post' ) : ?>
        <news:news>
            <news:publication>
                <news:name><?php bloginfo( 'name' ); ?></news:name>
                <news:language>en</news:language>
            </news:publication>
            <news:publication_date><?php echo esc_attr( $lastmod ); ?></news:publication_date>
            <news:title><?php echo esc_attr( get_the_title( $page->ID ) ); ?></news:title>
        </news:news>
        <?php endif; ?>
    </url>
        <?php
    }

    // === Taxonomy Terms (categories, tags, etc.) ===
    $taxonomies = get_taxonomies( [ 'public' => true ], 'names' );

    foreach ( $taxonomies as $taxonomy ) {
        $terms = get_terms( [
            'taxonomy'   => $taxonomy,
            'hide_empty' => true,
        ] );

        if ( empty( $terms ) || is_wp_error( $terms ) ) {
            continue;
        }

        foreach ( $terms as $term ) {
            $permalink = get_term_link( $term );
            if ( is_wp_error( $permalink ) ) {
                continue;
            }

            // Get latest modified post in this term — NO tax_query → no warning!
            $object_ids = get_objects_in_term( $term->term_id, $taxonomy );
            if ( empty( $object_ids ) || is_wp_error( $object_ids ) ) {
                $lastmod = gmdate( 'c' );
            } else {
                $latest = get_posts( [
                    'post_type'              => 'any',
                    'post_status'            => 'publish',
                    'include'                => $object_ids,
                    'posts_per_page'         => 1,
                    'orderby'                => 'modified',
                    'order'                  => 'DESC',
                    'no_found_rows'          => true,
                    'update_post_meta_cache' => false,
                    'update_post_term_cache' => false,
                ] );
                $lastmod = ! empty( $latest ) ? get_the_modified_date( 'c', $latest[0] ) : gmdate( 'c' );
            }
            ?>
    <url>
        <loc><?php echo esc_url( $permalink ); ?></loc>
        <lastmod><?php echo esc_attr( $lastmod ); ?></lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.6</priority>
    </url>
            <?php
        }
    }
    ?>
</urlset>
    <?php
    exit;
}
add_action( 'init', 'clarity_seo_generate_sitemap' );

// Virtual robots.txt
function clarity_seo_generate_robots_txt( $output, $public ) {
    if ( $public ) {
        $output .= "User-agent: *\n";
        $output .= "Allow: /\n";
        $output .= "Sitemap: " . esc_url( home_url( '/sitemap.xml' ) ) . "\n";
    }
    return $output;
}
add_filter( 'robots_txt', 'clarity_seo_generate_robots_txt', 10, 2 );

Youez - 2016 - github.com/yon3zu
LinuXploit