Page 1 of 1

Custom phpBB PM notification into any WordPress menu/theme HOW to

Posted: Sun Apr 05, 2020 2:08 pm
by axew3
English more below in reply!

Funziona per forza, magari va aggiunto anche di eseguire solo se utente loggato, ma non dovrebbe essere necessario, comunque, l'ul che contiene i li delle items voci di menu
sul tuo output html della pagina è: primary-menu
quindi questa linea sul codice:

Code: Select all

$elemID = empty($elemID) ? 'menu-main1' : $elemID;
dovrà essere:

Code: Select all

$elemID = empty($elemID) ? 'primary-menu' : $elemID;
e menu-item class, per puntare correttamente allo style da applicare all'elemento class=\"menu-item\"
magari necessario, magari no, per far apparire il buttone/link, uguale agli altri del menu

Lo snippet che funziona per il tuo tema quindi (scusa la piccola confusione, è stato anche leggermente perfezionato) sarà esattamente cosi:


BEFORE this line into wp_w3all.php

Code: Select all

// workaround for password on Signups: see wp_hash_password() here below

ADD this code:

Code: Select all

add_action('wp_head','wp_w3all_new_phpbbpm_pushJS');

function wp_w3all_new_phpbbpm_pushJS($elemID, $msg='') {
 global $w3all_custom_output_files, $w3all_iframe_phpbb_link_yn, $wp_w3all_forum_folder_wp, $w3all_url_to_cms;

if ( is_user_logged_in() ) {
	
 // NOTE: primary-menu OR THE ID of the UL that contain li menu items	
 $elemID = empty($elemID) ? 'primary-menu' : $elemID;

if ( defined("W3PHPBBUSESSION") ) {
 $phpbb_user_session = unserialize(W3PHPBBUSESSION);
   if($phpbb_user_session[0]->user_unread_privmsg > 0){
	
	if ($w3all_iframe_phpbb_link_yn > 0){
		$w3all_url_to_phpbb_ib = get_home_url() . "/" . $wp_w3all_forum_folder_wp . "/?i=pm&folder=inbox";
	} else {
	        $w3all_url_to_phpbb_ib = $w3all_url_to_cms . "/ucp.php?i=pm&folder=inbox";
         }
        
$s = "<script>
jQuery(document).ready(function($) {
 var msgs = '".__( 'You have ', 'wp-w3all-phpbb-integration' )."' + ".$phpbb_user_session[0]->user_unread_privmsg." + '".__( ' unread forum PM', 'wp-w3all-phpbb-integration' )."';
 jQuery('#".$elemID."').append('<li id=\"menu-item-99\" class=\"menu-item\"><a href=\"".$w3all_url_to_phpbb_ib."\">' + msgs + '</li>');
});

</script>
<style type=\"text/css\" media=\"screen\">
</style>";
	echo $s;
	
   }
  }
 }
}

Re: Custom phpBB PM notification into any WordPress menu/theme HOW to

Posted: Sun Apr 05, 2020 2:36 pm
by axew3
EXPLAINED in English:

To add custom PM notification (this will be option in next releases, it's just a temporary snippet, by the way completely working and will not differ too much by the definitive) into any WordPress theme/menu, you need to know what is the UL element that wrap li menu items, then into the snippet code here below, change this line:

Code: Select all

$elemID = empty($elemID) ? 'primary-menu' : $elemID;
to fit your UL container

Code: Select all

$elemID = empty($elemID) ? 'YOUR-UL-ID-HERE' : $elemID;
AND menu-item class, to match the class of your theme menu where class=\"menu-item\"
so if necessary, the link will may look the same like others menu buttons/links

the code to add, into the wp_w3all.php file, may just BEFORE this line

Code: Select all

// workaround for password on Signups: see wp_hash_password() here below
Is This:

Code: Select all

add_action('wp_head','wp_w3all_new_phpbbpm_pushJS');
function wp_w3all_new_phpbbpm_pushJS($elemID, $msg='') {
 global $w3all_custom_output_files, $w3all_iframe_phpbb_link_yn, $wp_w3all_forum_folder_wp, $w3all_url_to_cms;

if ( is_user_logged_in() ) {
	
 // NOTE: primary-menu OR THE ID of the UL that contain li menu items	
 $elemID = empty($elemID) ? 'primary-menu' : $elemID;

if ( defined("W3PHPBBUSESSION") ) {
 $phpbb_user_session = unserialize(W3PHPBBUSESSION);
   if($phpbb_user_session[0]->user_unread_privmsg > 0){
	
	if ($w3all_iframe_phpbb_link_yn > 0){
		$w3all_url_to_phpbb_ib = get_home_url() . "/" . $wp_w3all_forum_folder_wp . "/?i=pm&folder=inbox";
	} else {
	        $w3all_url_to_phpbb_ib = $w3all_url_to_cms . "/ucp.php?i=pm&folder=inbox";
         }
        
$s = "<script>
jQuery(document).ready(function($) {
 var msgs = '".__( 'You have ', 'wp-w3all-phpbb-integration' )."' + ".$phpbb_user_session[0]->user_unread_privmsg." + '".__( ' unread forum PM', 'wp-w3all-phpbb-integration' )."';
 jQuery('#".$elemID."').append('<li id=\"menu-item-99\" class=\"menu-item\"><a href=\"".$w3all_url_to_phpbb_ib."\">' + msgs + '</li>');
});

</script>
<style type=\"text/css\" media=\"screen\">
</style>";
	echo $s;
	
   }
  }
 }
}

Stay cool lovely people!

phpbb_pm_notification_wordpress_menu.png
phpbb_pm_notification_wordpress_menu.png (31.67 KiB) Viewed 4006 times

Re: Custom phpBB PM notification into any WordPress menu/theme HOW to

Posted: Thu Apr 09, 2020 9:58 pm
by zeus
Hello ( sono sempre io ) :-)
for sure is simple, but i'm totally new to CSS style and so on...
How can I change the background and text color of the "button" menù ?

Probably changing these lines, but how ? :-)

Code: Select all

<style type=\"text/css\" media=\"screen\">
body {background-color:#034f84;}
</style>";

Ciao !

Re: Custom phpBB PM notification into any WordPress menu/theme HOW to

Posted: Fri Apr 10, 2020 7:15 am
by axew3
Ciao!
The pushed/added via javascript, link background onmouseover, have a different color by others or you want to change all links background?

The code snippet above, add the code into wordpress footer, then, it is not useful to add (is an html error)

Code: Select all

<style type="text/css" media="screen">
</style>";
because will output on footer, and NOT on header (where css style need to be added in case).

Going to edit the above, that to work, and correctly output on header, this line:

Code: Select all

add_action('wp_footer','wp_w3all_new_phpbbpm_pushJS');
NEED TO BE CHANGED INTO:

Code: Select all

add_action('wp_head','wp_w3all_new_phpbbpm_pushJS');
then all will work fine

Se hai ancora problemi fa sapere, non ho ben capito cosa esattamente vuoi fare, facendo il cambio come detto sopra, il css che andrai ad applicare funzionerà correttamente, perchè l'output sarà sulla header

Re: Custom phpBB PM notification into any WordPress menu/theme HOW to

Posted: Fri Apr 10, 2020 12:10 pm
by zeus
All fine, thanks !

Volevo solo cambiar elo sfondo del "bottone" quando salta l'allerta per nuovi messaggi pvt.
Grazie mille ;)

Re: Custom phpBB PM notification into any WordPress menu/theme HOW to

Posted: Sun Apr 12, 2020 1:18 pm
by axew3
L'altro post è stato spostato qui:
viewtopic.php?f=2&t=1523
stò controllando se cambiando i setting della data in wp succede il problema... rispondo li tra poco, ciao