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
$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()) {
while ($query->have_posts()) {
$query->the_post();
$output .= '
' . esc_html(get_the_title()) . '';
// Show the published date if the setting is enabled
if (strtolower($show_date) === 'yes') {
$output .= ' - ' . esc_html(get_the_date()) . ''; // Display published date
}
if (strtolower(sanitize_text_field($atts['date_modified'])) === 'yes') {
$output .= ' - ' . esc_html(get_the_modified_date()) . '';
}
$output .= '