function WPLinkedInAdmin($plugin) { $this->plugin = $plugin; $this->linkedin = wp_linkedin_connection(); $this->add_settings(); add_action('admin_notices', array(&$this, 'admin_notices')); }
function field_access_token() { $linkedin = wp_linkedin_connection(); ?> <input readonly type="text" class="large-text" value="<?php esc_attr_e($linkedin->get_access_token()); ?> " /><?php }
function template_redirect() { if (get_query_var('oauth') == 'linkedin') { $linkedin = wp_linkedin_connection(); $linkedin->process_authorization(get_query_var('code'), get_query_var('state'), get_query_var('r')); exit; } }
function template_redirect() { if (is_user_logged_in() && get_query_var('oauth') == 'linkedin') { $linkedin = wp_linkedin_connection(); $state = get_query_var('state'); $code = get_query_var('code'); $r = get_query_var('r'); if ($linkedin->check_state_token($state)) { $retcode = $linkedin->set_access_token($code, $r); if (!is_wp_error($retcode)) { $linkedin->clear_cache(); $this->redirect($r, 'success'); } else { $this->redirect($r, 'error', $retcode->get_error_message()); } } else { $this->redirect($r, 'error', __('Invalid state', 'wp-linkedin')); } exit; } }
function admin_notices() { if (!WP_LINKEDIN_APPKEY && current_user_can('manage_options') && !is_multisite()) { $format = __('Your must create an application key/secret to access the LinkedIn API. Please follow the instructions <a href="%s">on the settings page</a>.', 'wp-linkedin'); $notice = sprintf($format, admin_url('options-general.php?page=wp-linkedin#apikeys')); ?> <div class="notice notice-error"><p><?php echo $notice; ?> </p></div><?php return; } $linkedin = wp_linkedin_connection(); if (!$linkedin->is_access_token_valid()) { $format = __('Your LinkedIn access token is invalid or has expired, please <a href="%s">click here</a> to get a new one.', 'wp-linkedin'); $notice = sprintf($format, $linkedin->get_authorization_url()); ?> <div class="notice notice-warning"><p><?php echo $notice; ?> </p></div><?php } if (LI_DEBUG && $linkedin->get_last_error()) { ?> <div class="notice notice-error"> <p><?php _e('An error has occured while retrieving the profile:', 'wp-linkedin'); ?> <?php echo $linkedin->get_last_error(); ?> </p> </div><?php } if (isset($_GET['oauth_status'])) { switch ($_GET['oauth_status']) { case 'success': $message = isset($_GET['oauth_message']) ? $_GET['oauth_message'] : __('The access token has been successfully updated.', 'wp-linkedin'); ?> <div class="notice notice-success is-dismissible"><p><?php echo $message; ?> </p></div><?php break; case 'error': $message = isset($_GET['oauth_message']) ? $_GET['oauth_message'] : false; ?> <div class="notice notice-error is-dismissible"> <p><?php _e('An error has occured while updating the access token, please try again.', 'wp-linkedin'); ?> <?php echo $message ? '<br/>' . __('Error message: ', 'wp-linkedin') . $message : ''; ?> </p> </div><?php break; } } if (isset($_GET['cache_cleared'])) { ?> <div class="notice notice-success"><p><?php _e('The cache has been cleared.', 'wp-linkedin'); ?> </p></div><?php } }