Web Docs';
}
return $links;
}
add_filter('plugin_row_meta', 'advance_catlist_post_plugin_meta', 10, 2);
// Enqueue the CSS file
function advance_catlist_post_enqueue_styles() {
wp_enqueue_style('advance-catlist-post-style', plugin_dir_url(__FILE__) . 'assets/style.css');
}
add_action('wp_enqueue_scripts', 'advance_catlist_post_enqueue_styles');
// Shortcode Logic
function advance_catlist_post_shortcode($atts) {
$default_number_of_posts = get_option('default_number_of_posts', 5);
$show_date = get_option('show_date', 'no'); // Get the setting for showing date
$show_new_gif = get_option('show_new_gif', 'no');
$new_gif_post_count = get_option('new_gif_post_count', 3); // Default number of posts for New GIF
$atts = shortcode_atts(array(
'name' => '',
'date_modified' => 'no',
'date_class' => 'icp_date',
'numberposts' => $default_number_of_posts,
), $atts, 'catlist');
$args = array(
'posts_per_page' => intval($atts['numberposts']),
);
if (!empty($atts['name'])) {
$args['category_name'] = sanitize_text_field($atts['name']);
}
$query = new WP_Query($args);
$output = '
';
if ($query->have_posts()) {
$post_count = 0; // Counter to display "New" GIF for top posts
while ($query->have_posts()) {
$query->the_post();
$post_count++; // Increment counter per post
$output .= '
' . esc_html(get_the_title()) . '';
// Show "New" GIF for top posts as per the setting
if ($show_new_gif === 'yes' && $post_count <= $new_gif_post_count) {
$output .= ' ';
}
// Show published or modified date as per settings
if (strtolower($show_date) === 'yes') {
$output .= ' - ' . esc_html(get_the_date()) . '';
}
if (strtolower(sanitize_text_field($atts['date_modified'])) === 'yes') {
$output .= ' - ' . esc_html(get_the_modified_date()) . '';
}
$output .= '