403Webshell
Server IP : 65.108.144.40  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User : dev ( 1000)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/successkpi/wp-content/themes/successkpi/blocks/editor-picks-block/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/successkpi/wp-content/themes/successkpi/blocks/editor-picks-block/index.php
<?php
/**
 * Editor's Picks Block Template.
 */
if (
    function_exists('render_block_preview_image') &&
    render_block_preview_image($block, 'Editor Picks Block preview')
) {
    return;
}
$className = 'featured_post_block ' . (isset($block['className']) ? $block['className'] : '');
$featured_selection = get_field('featured_editor_pick');
$featured_post_id   = false;
if ($featured_selection) {
    if (is_array($featured_selection)) {
        $first_item = $featured_selection[0];
        $featured_post_id = is_object($first_item) ? (isset($first_item->ID) ? $first_item->ID : false) : $first_item;
    } elseif (is_object($featured_selection)) {
        $featured_post_id = isset($featured_selection->ID) ? $featured_selection->ID : false;
    } else {
        $featured_post_id = $featured_selection;
    }
}
// Fallback: If no post selected, fetch the latest post from allowed post types
if (!$featured_post_id) {
    $field_config = acf_get_field('featured_editor_pick');
    $allowed_types = (isset($field_config['post_type']) && !empty($field_config['post_type'])) 
        ? $field_config['post_type'] 
        : array('post', 'webinars', 'guides', 'success-stories', 'reports', 'videos');
    $featured_fallback_query = new WP_Query(array(
        'post_type'      => $allowed_types,
        'posts_per_page' => 1,
        'post_status'    => 'publish',
        'orderby'        => 'date',
        'order'          => 'DESC',
    ));
    if ($featured_fallback_query->have_posts()) {
        $featured_post_id = $featured_fallback_query->posts[0]->ID;
    }
    wp_reset_postdata();
}
if ($featured_post_id) {
    $featured_post = get_post($featured_post_id);
    $featured_title = get_the_title($featured_post_id);
    $featured_permalink = get_permalink($featured_post_id);
    $card_url = $featured_permalink;
    $image_url = get_the_post_thumbnail_url($featured_post_id, 'large');
    $image_alt = get_post_meta(get_post_thumbnail_id($featured_post_id), '_wp_attachment_image_alt', true);
    if (empty($image_alt)) {
        $image_alt = $featured_title;
    }
    $custom_type_label = get_field('featured_type_label');
    $custom_cta_label  = get_field('featured_cta_label');
    if (!empty($custom_type_label)) {
        $type_label = $custom_type_label;
    } else {
        $f_post_type = get_post_type($featured_post_id);
        if ($f_post_type === 'webinars') {
            $type_label = 'On Demand Webinar';
        } elseif ($f_post_type === 'post') {
            $type_label = 'Blog';
        } else {
            $pt_obj = get_post_type_object($f_post_type);
            $type_label = (isset($pt_obj->labels->singular_name)) ? $pt_obj->labels->singular_name : ucfirst($f_post_type);
        }
    }
    $cta_label = !empty($custom_cta_label) ? $custom_cta_label : 'Read More';
    $raw_excerpt = trim($featured_post->post_excerpt);
    if (!empty($raw_excerpt)) {
        $featured_excerpt = wp_trim_words(wp_strip_all_tags($raw_excerpt), 25, '.');
    } else {
        $featured_excerpt = wp_trim_words(wp_strip_all_tags(strip_shortcodes($featured_post->post_content)), 25, '.');
    }
    $content = wp_strip_all_tags($featured_post->post_content);
    $word_count = str_word_count($content);
    $reading_time = ceil($word_count / 200);
    if ($reading_time < 1) {
        $reading_time = 1;
    }
}
$list_heading  = get_field('editor_pick_heading') ?: "Editor's Picks";
$repeater_data = get_field('editor_picked_posts');
$editors_picks = array();
if (!empty($repeater_data) && is_array($repeater_data)) {
    foreach ($repeater_data as $row) {
        $row_post_selection = isset($row['post']) ? $row['post'] : false;
        $row_post_id = false;
        if ($row_post_selection) {
            if (is_array($row_post_selection)) {
                $item = $row_post_selection[0];
                $row_post_id = is_object($item) ? (isset($item->ID) ? $item->ID : false) : $item;
            } elseif (is_object($row_post_selection)) {
                $row_post_id = isset($row_post_selection->ID) ? $row_post_selection->ID : false;
            } else {
                $row_post_id = $row_post_selection;
            }
        }
        if ($row_post_id) {
            $p_type = get_post_type($row_post_id);
            if ($p_type === 'post') {
                $label = 'Blog';
            } else {
                $p_obj = get_post_type_object($p_type);
                $label = (isset($p_obj->labels->singular_name)) ? $p_obj->labels->singular_name : ucfirst($p_type);
            }
            $editors_picks[] = array(
                'post_id'   => $row_post_id,
                'label'     => $label,
                'type_slug' => $p_type,
            );
        }
    }
}
// Fallback: If repeater is empty, fetch latest from 'reports', 'guides', 'success-stories', 'post'
if (empty($editors_picks)) {
    $fallback_types = array('reports', 'guides', 'success-stories', 'post');
    foreach ($fallback_types as $type) {
        $p_query = new WP_Query(array(
            'post_type'      => $type,
            'posts_per_page' => 1,
            'post_status'    => 'publish',
            'orderby'        => 'date',
            'order'          => 'DESC',
        ));
        if ($p_query->have_posts()) {
            $p_id = $p_query->posts[0]->ID;
            if ($type === 'post') {
                $label = 'Blog';
            } else {
                $p_obj = get_post_type_object($type);
                $label = (isset($p_obj->labels->singular_name)) ? $p_obj->labels->singular_name : ucfirst($type);
            }
            $editors_picks[] = array(
                'post_id'   => $p_id,
                'label'     => $label,
                'type_slug' => $type,
            );
        }
        wp_reset_postdata();
    }
}
if (!isset($featured_post_id) || !$featured_post_id) {
    if (is_admin()) {
        echo '<div style="padding:20px;border:1px dashed #ccc;">Editor Picks Block: No posts found for display.</div>';
    }
    return;
}
?>
<section class="<?php echo esc_attr(trim($className)); ?>">
    <div class="container">
        <div class="featured-posts-wrapper">
            <div class="left-content" data-aos="fade-up">
                <a href="<?php echo esc_url($card_url); ?>" class="img-wrapper aspect-ratio">
                    <?php if (!empty($featured_title)) : ?>
                        <h2><?php echo esc_html($featured_title); ?></h2>
                    <?php endif; ?>
                    <div class="featured-post-image">
                        <?php if (!empty($image_url)) : ?>
                            <img src="<?php echo esc_url($image_url); ?>" alt="<?php echo esc_attr($image_alt); ?>" />
                        <?php endif; ?>
                    </div>
                    <?php if (!empty($type_label)) : ?>
                        <span class="sk-ep-tag"><?php echo esc_html($type_label); ?></span>
                    <?php endif; ?>
                    <?php if (!empty($featured_excerpt)) : ?>
                        <p><?php echo esc_html($featured_excerpt); ?></p>
                    <?php endif; ?>
                    <div class="sk-resource-info-detail-row">
                        <div class="sk-resource-info-detail">
                            <span><?php echo esc_html(get_the_date('F j, Y', $featured_post_id)); ?></span>
                            <span><?php echo esc_html($reading_time); ?> minute read</span>
                        </div>
                        <span class="featured-post-link"><?php echo esc_html($cta_label); ?></span>
                    </div>
                </a>
            </div>
            <?php if (!empty($editors_picks)) : ?>
                <div class="sk-editors-picks" data-aos="fade-up">
                    <h3><?php echo esc_html($list_heading); ?></h3>
                    <div class="sk-ep-list">
                        <?php foreach ($editors_picks as $pick) : ?>
                            <a class="sk-ep-item" href="<?php echo esc_url(get_permalink($pick['post_id'])); ?>" data-aos="fade-up">
                                <span class="sk-ep-tag" id="color-<?php echo esc_attr($pick['type_slug']); ?>">
                                    <?php echo esc_html($pick['label']); ?>
                                </span>
                                <p><?php echo esc_html(get_the_title($pick['post_id'])); ?></p>
                            </a>
                        <?php endforeach; ?>
                    </div>
                </div>
            <?php endif; ?>
        </div>
    </div>
</section>

Youez - 2016 - github.com/yon3zu
LinuXploit