mozilla / wp-web-push

Web Push plugin for WordPress - no longer actively maintained
https://wordpress.org/plugins/web-push/
Other
39 stars 15 forks source link

Examples #326

Open Mte90 opened 8 years ago

Mte90 commented 8 years ago

Will be amazing to have examples and not to look on the tests to understand how to create a new notification.

Mte90 commented 8 years ago
function web_push_notification( $title, $content, $url, $icon = '' ) {
    if ( class_exists( 'WebPush_Main' ) ) {
    if ( empty( $icon ) ) {
      $icon_option = get_option( 'webpush_icon' );
      if ( $icon_option === 'blog_icon' ) {
        $icon = get_site_icon_url();
      } elseif ( $icon_option !== 'blog_icon' && $icon_option !== '' && $icon_option !== 'post_icon' ) {
        $icon = $icon_option;
      }
    }
    WebPush_Main::sendNotification( $title, $content, $icon, $url, null );
    }
  }

I think that can go on the readme :-D