Created
April 26, 2025 05:54
-
-
Save BhargavBhandari90/4e1fc563689596e637149ad1cd6fc16b to your computer and use it in GitHub Desktop.
WordPress infinite loop without timeout for doing anything.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function buntywp_infinite_loop() { | |
if ( ! is_admin() && isset( $_GET['generate_data'] ) ) { | |
if ( current_user_can( 'administrator' ) ) { | |
$page = filter_input( INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT ); | |
if ( empty( $page ) ) { | |
$page = 1; | |
} | |
$limit = 10; | |
// Query all the replies. | |
$topic_query = new WP_Query( | |
array( | |
'post_type' => 'topic', | |
'post_status' => 'publish', | |
'paged' => $page, | |
'posts_per_page' => $limit, | |
'order' => 'ASC', | |
) | |
); | |
if ( $topic_query->have_posts() ) { | |
while ( $topic_query->have_posts() ) { | |
$topic_query->the_post(); | |
// Do whatever you want to do. | |
} | |
wp_reset_postdata(); | |
?> | |
<script> | |
window.location.href = '<?php echo site_url() . '/?generate_data=1&pg=' . ( $page + 1 ); ?>'; | |
</script> | |
<?php | |
} | |
} else { | |
echo 'You are caught!!!! ;) You are DEAD now...!!!!!'; | |
die; | |
} | |
} | |
} | |
add_action( 'init', 'buntywp_infinite_loop' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Follow these STEPS:
your_site_url/?generate_data=1