/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. * @return void */ public function widget($args, $instance) { $title = !empty($instance['title']) ? $instance['title'] : 'Memberful Profile'; $title = apply_filters('widget_title', $title); $args['title'] = $title; $args['signed_in_links'] = array(array('href' => memberful_account_url(), 'class' => 'memberful-account-link', 'text' => __('Account')), array('href' => memberful_sign_out_url(), 'class' => 'memberful-sign-out-link', 'text' => __('Sign out'))); $args['signed_out_links'] = array(array('href' => memberful_sign_in_url(is_ssl() ? 'https' : 'http'), 'class' => 'memberful-sign-in-link', 'text' => __('Sign in'))); $args = apply_filters('memberful_wp_widget_args', $args); memberful_wp_render('profile_widget', $args); }
function memberful_wp_shortcode_account_link($atts, $content) { return '<a href="' . memberful_account_url() . '" role="account">' . do_shortcode($content) . '</a>'; }
/** * Gets information about a user from Memberful. * * @param string $access_token An access token which can be used to get info * about the member * @return array */ public function get_member_data($access_token) { $url = memberful_account_url(MEMBERFUL_JSON); $response = memberful_wp_get_data_from_api(add_query_arg('access_token', $access_token, $url), 'get_member_data_for_sign_in'); if (is_wp_error($response)) { return $this->_error('fetch_account_connect_failure', $response); } $body = json_decode($response['body']); $code = $response['response']['code']; if ($code != 200 or $body === NULL) { return $this->_error('fetch_account_response_failure', 'Could not fetch your data from Memberful. ' . $code); } return $body; }