Skip to content

Instantly share code, notes, and snippets.

@8ivek
Last active July 14, 2023 21:26
Show Gist options
  • Save 8ivek/40a8a3f536dae66eb6a667d32a2356cc to your computer and use it in GitHub Desktop.
Save 8ivek/40a8a3f536dae66eb6a667d32a2356cc to your computer and use it in GitHub Desktop.
run one time code in Wordpress
<?php
// running one time script in wordpress
function oneTimeFunction($arguments)
{
// One time task goes here
}
add_action('wp_loaded', function () {
if (isset($_GET['unique_argument_xx007']) && $_GET['unique_argument_xx007'] === 'unique_value_xx007') {
if (!get_option('random_option_xx007')) {
oneTimeFunction($arguments);
add_option('random_option_xx007', 1);
}
}
});
// calling:
// https://yourdomain.com/?unique_argument_xx007=unique_value_xx007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment