From 42e8cbc4e99756e43344e0ac9dc8ab1bbe05d0cf Mon Sep 17 00:00:00 2001 From: asus Date: Wed, 27 Mar 2024 18:54:57 +0100 Subject: [PATCH] cipf v 0.4.4 added randomization for posts if < -1 --- plugins/cipf_plugin/cipf_plugin.php | 1 + plugins/cipf_plugin/php/random_posts.php | 41 ++++++++++++++++++++++++ plugins/custer/custer.php | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 plugins/cipf_plugin/php/random_posts.php diff --git a/plugins/cipf_plugin/cipf_plugin.php b/plugins/cipf_plugin/cipf_plugin.php index 112b11e..b6c4ab1 100644 --- a/plugins/cipf_plugin/cipf_plugin.php +++ b/plugins/cipf_plugin/cipf_plugin.php @@ -50,6 +50,7 @@ include_once(PLGNTLS_class::root_path() . 'php/partners_page.php'); include_once(PLGNTLS_class::root_path() . 'php/display_css.php'); include_once(PLGNTLS_class::root_path() . 'php/payments.php'); include_once(PLGNTLS_class::root_path() . 'php/email_registration.php'); +include_once(PLGNTLS_class::root_path() . 'php/random_posts.php'); diff --git a/plugins/cipf_plugin/php/random_posts.php b/plugins/cipf_plugin/php/random_posts.php new file mode 100644 index 0000000..e3149d2 --- /dev/null +++ b/plugins/cipf_plugin/php/random_posts.php @@ -0,0 +1,41 @@ + so this randomization will not work for 1 post +* +*/ +function randomize_post_output_CIPF($query) { + PLGNTLS_class::debug_infos(2); + $posts_per_page = $query->get('posts_per_page'); + if (is_null($posts_per_page)) { + return; + } + if ($posts_per_page >= -1) { + return; + } + PLGNTLS_class::debug_infos(); + + error_log("posts_per_page: " . json_encode($posts_per_page)); + $query->set('orderby', 'rand'); +} +add_action('pre_get_posts', 'randomize_post_output_CIPF'); + + + + + + +?> diff --git a/plugins/custer/custer.php b/plugins/custer/custer.php index 13fdf26..9a758fc 100644 --- a/plugins/custer/custer.php +++ b/plugins/custer/custer.php @@ -4,7 +4,7 @@ Plugin Name: custer_plugin Plugin URI: Description: customize user : output infos on page, on email, and change current user id momentarly Author: hugogogo -Version: 0.1.7 +Version: 0.1.8 Author URI: */