public static function admin_menu_page() { $roost_settings = self::roost_settings(); $app_key = $roost_settings['appKey']; $app_secret = $roost_settings['appSecret']; $chrome_error_dismiss = $roost_settings['chrome_error_dismiss']; $cat_args = array('hide_empty' => 0, 'order' => 'ASC'); $cats = get_categories($cat_args); if (true === self::roost_active()) { $bbPress_active = Roost_bbPress::bbPress_active(); $roost_active_key = true; } else { $roost_active_key = false; } if (true === self::roost_active() && empty($roost_server_settings)) { $roost_server_settings = Roost_API::get_server_settings($app_key, $app_secret); $roost_stats = Roost_API::get_stats($app_key, $app_secret); } if (false === self::roost_active() && isset($_GET['roost_token'])) { $roost_token = $_GET['roost_token']; $roost_token = urldecode($roost_token); $logged_in = Roost_API::login(null, null, $roost_token); $response = self::complete_login($logged_in, null); $first_time = $response['firstTime']; $roost_server_settings = $response['server_settings']; $roost_stats = $response['stats']; $roost_active_key = true; } if (isset($_POST['roostlogin'])) { $roost_user = $_POST['roostuserlogin']; $roost_pass = $_POST['roostpasslogin']; $logged_in = Roost_API::login($roost_user, $roost_pass, null); $response = self::complete_login($logged_in, null); if (empty($response['status'])) { $roost_sites = $response; } else { if (!empty($response['firstTime'])) { $first_time = $response['firstTime']; $roost_server_settings = $response['server_settings']; $roost_stats = $response['stats']; $roost_active_key = true; } else { $status = $response['status']; } } } if (isset($_POST['roostconfigselect'])) { $selected_site = sanitize_text_field($_POST['roostsites']); if ('none' === $selected_site) { $status = 'You must select a site.'; $roost_server_settings = null; $roost_stats = null; } else { $site = explode('|', $selected_site); $response = self::complete_login(null, $site); $first_time = $response['firstTime']; $roost_server_settings = $response['server_settings']; $roost_stats = $response['stats']; $roost_active_key = true; } } if (isset($_GET['status'])) { $status = urldecode($_GET['status']); } require_once dirname(plugin_dir_path(__FILE__)) . '/layout/admin.php'; }
public static function admin_menu_page() { $roost_settings = self::roost_settings(); $app_key = $roost_settings['appKey']; $app_secret = $roost_settings['appSecret']; if (true === self::roost_active()) { $bbPress_active = Roost_bbPress::bbPress_active(); $roost_active_key = true; } else { $roost_active_key = false; } if (true === self::roost_active() && empty($roost_server_settings)) { $roost_server_settings = Roost_API::get_server_settings($app_key, $app_secret); $roost_stats = Roost_API::get_stats($app_key, $app_secret); } if (false === self::roost_active() && isset($_GET['roost_token'])) { $roost_token = $_GET['roost_token']; $roost_token = urldecode($roost_token); $logged_in = Roost_API::login(null, null, $roost_token); $response = self::complete_login($logged_in, null); $first_time = $response['firstTime']; $roost_server_settings = $response['server_settings']; $roost_stats = $response['stats']; $roost_active_key = true; } if (isset($_POST['roostlogin'])) { $roost_user = $_POST['roostuserlogin']; $roost_pass = $_POST['roostpasslogin']; $logged_in = Roost_API::login($roost_user, $roost_pass, null); $response = self::complete_login($logged_in, null); if (empty($response['status'])) { $roost_sites = $response; } else { if (!empty($response['firstTime'])) { $first_time = $response['firstTime']; $roost_server_settings = $response['server_settings']; $roost_stats = $response['stats']; $roost_active_key = true; } else { $status = $response['status']; } } } if (isset($_POST['roostconfigselect'])) { $selected_site = $_POST['roostsites']; $site = explode('|', $selected_site); $response = self::complete_login(null, $site); $first_time = $response['firstTime']; $roost_server_settings = $response['server_settings']; $roost_stats = $response['stats']; $roost_active_key = true; } if (isset($_GET['status'])) { $status = urldecode($_GET['status']); } require_once dirname(plugin_dir_path(__FILE__)) . '/layout/admin.php'; }
public static function roost_bbp_notify_subscribers( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author = 0 ) { $topic_id = bbp_get_topic_id( $topic_id ); $forum_id = bbp_get_forum_id( $forum_id ); if ( ! bbp_is_topic_published( $topic_id ) ) { return false; } $topic_title = bbp_get_topic_title( $topic_id ); $topic_url = get_permalink( $topic_id ); if ( isset( $_POST['bbp_reply_to'] ) ) { $reply_to_id = $_POST['bbp_reply_to']; } $roost_settings = ROOST::roost_settings(); $app_key = $roost_settings['appKey']; $app_secret = $roost_settings['appSecret']; $message = 'New Post in ' . $topic_title; if ( ! empty( $reply_to_id ) ) { $reply_subscriptions = get_post_meta( $reply_to_id, '_roost_bbp_subscription', true ); } $topic_subscriptions = get_post_meta( $topic_id, '_roost_bbp_subscription', true ); $forum_subscriptions = get_post_meta( $forum_id, '_roost_bbp_subscription', true ); if ( ! empty( $reply_subscriptions ) ) { $device_tokens = array(); foreach( $reply_subscriptions as $token => $active ) { $device_tokens[] = $token; } } if ( ! empty( $topic_subscriptions ) ) { if ( empty( $device_tokens ) ) { $device_tokens = array(); } foreach( $topic_subscriptions as $token => $active ) { $device_tokens[] = $token; } } if ( ! empty( $forum_subscriptions ) ) { if ( empty( $device_tokens ) ) { $device_tokens = array(); } foreach( $forum_subscriptions as $token => $active ) { $device_tokens[] = $token; } } if ( empty( $device_tokens) ) { return; } Roost_API::send_notification( $message, $topic_url, null, $app_key, $app_secret, $device_tokens, null ); }