0

I am getting this warning message while creating my plugin. Is Anyone available to help me in this issue.

Error:

The %i modifier is only supported in WP 6.2 or higher. Found: "%i".

Source code:

class CFBP_Shortcode { public static function render($atts) { global $wpdb; $id = isset($atts['id']) ? intval($atts['id']) : 0; // $unique_id = 'cfbp_' . $id . '_' . uniqid(); // Unique wrapper ID $unique_id = 'cfbp_' . $id; // Unique wrapper ID if (!$id) return ''; $cache_key = 'cfbp_row_' . $id; $row = wp_cache_get($cache_key, 'cfbp'); if ($row === false) { $table = esc_sql(CFBP_DB_TABLE); $row = $wpdb->get_row($wpdb->prepare("SELECT * FROM %i WHERE id = %d", [$table, $id])); if ($row) { wp_cache_set($cache_key, $row, 'cfbp', HOUR_IN_SECONDS); } } if (!$row) return ''; $paged = get_query_var('paged') ?: (get_query_var('page') ?: 1); $args = [ 'post_type' => 'post', 'posts_per_page' => $row->post_count, 'paged' => $paged, 'orderby' => ($row->show_type === 'random') ? 'rand' : 'date', ]; $query = new WP_Query($args); ob_start(); echo '<div id="my-id' . esc_attr($unique_id) . '" class="cfbp-grid-wrapper" data-shortcode-id="'.esc_attr($unique_id).'">'; echo '<div class="cfbp-grid ' . esc_attr($row->custom_class) . '">'; while ($query->have_posts()) : $query->the_post(); ?> <div class="cfbp-post"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> </div> <?php endwhile; echo '</div>'; // end .cfbp-grid //Pagination block starts here $total_pages = $query->max_num_pages; $current_page = max(1, $paged); echo '<div class="cfbp-pagination">'; if ($current_page > 1) { echo '<a href="' . esc_url(get_pagenum_link($current_page - 1)) . '" class="cfbp-prev"> < </a> '; } else { echo '<span class="cfbp-prev disabled"> < </span> '; } echo '<span class="cfbp-page-info">Page ' . esc_html($current_page) . ' of ' . esc_html($total_pages) . '</span> '; if ($current_page < $total_pages) { echo '<a href="' . esc_url(get_pagenum_link($current_page + 1)) . '" class="cfbp-next"> > </a>'; } else { echo '<span class="cfbp-next disabled"> > </span>'; } echo '</div>'; // end .cfbp-pagination echo '</div>'; // end .cfbp-grid-wrapper wp_reset_postdata(); return ob_get_clean(); } public static function init() { add_action('wp_enqueue_scripts', [self::class, 'enqueue_assets']); add_shortcode('cfbp_shortcode', [self::class, 'render']); } public static function enqueue_assets() { $css_path = CFBP_PLUGIN_DIR . 'assets/css/cfbp-style.css'; $css_version = file_exists($css_path) ? filemtime($css_path) : false; wp_enqueue_style('cfbp-style', CFBP_PLUGIN_URL . 'assets/css/cfbp-style.css', array(), $css_version); $js_path = CFBP_PLUGIN_DIR . 'assets/js/cfbp-ajax.js'; $js_version = file_exists($js_path) ? filemtime($js_path) : false; wp_enqueue_script('cfbp-ajax', CFBP_PLUGIN_URL . 'assets/js/cfbp-ajax.js', ['jquery'], $js_version, true); wp_localize_script('cfbp-ajax', 'cfbp_ajax_obj', [ 'ajax_url' => admin_url('admin-ajax.php'), ]); } } 
1
  • Please edit your question to include a [mre] so that readers can run your code to answer your question. Commented Aug 29 at 9:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.