Ok, it is a problem of the init that run after the setup of the theme’s template files.
So that to explain to you the problem, let say i test it into a default twentysixteen theme.
i go to open the file
/wp-content/themes/twentysixteen/functions.php
then i go to add the snippet to get the global var $w3all_phpbb_unotifications;
global $w3all_phpbb_unotifications;
print_r($w3all_phpbb_unotifications);exit;
INSIDE THE FUNCTION
function twentysixteen_setup() {
will NOT WORK. This function fire before the plugin code.
it is hooked into the after_setup_theme hook
add_action( 'after_setup_theme', 'twentysixteen_setup' );
but let instead add the code to get the result you want, inside another function that hook into wp_head:
add_action( 'wp_head', 'twentysixteen_javascript_detection', 0 );
so search for
function twentysixteen_javascript_detection() {
and inside this function put the code:
function twentysixteen_javascript_detection() {
global $w3all_phpbb_unotifications;
if(empty($w3all_phpbb_unotifications)){
$nnum = 0; } else { $nnum = count($w3all_phpbb_unotifications);
// echo $nnum; exit;
}
now you get the result.
So, TO RESUME you can get the result you want also doing/ADDING this into your (ANY THEME) functions.php template file:
function phpbb_notifications() {
global $w3all_phpbb_unotifications;
if(!empty($w3all_phpbb_unotifications)){
//print_r(count($w3all_phpbb_unotifications));exit;
echo'<script>var w3notificationsCount = '.count($w3all_phpbb_unotifications).';</script>';
} else {
echo'<script>var w3notificationsCount = 0;</script>'; // or remmove and check in javascript after, if the var exist, to detect that the user have or do not have new notifications
}
}
add_action( 'wp_head', 'phpbb_notifications', 0 );
use these two ready plugins files, the code will not change on 2.6.6 about this. You’ll have just to enable the new added and related option, into the plugin admin preferences on next 2.6.6 (will be Retrieve user’s phpBB notifications)
https://github.com/axew3/common-test-files/archive/refs/heads/main.zip
download the two zipped files and replace into folder
/wp-content/plugins/wp-w3all-phpbb-integration/
– we’ll never give up!
-
This reply was modified 2 years, 5 months ago by
axew3.
-
This reply was modified 2 years, 5 months ago by
axew3.
-
This reply was modified 2 years, 5 months ago by
axew3.