This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add a new endpoint and functionality to WordPress OAuth Server. | |
* This snippet would go in your functions file. | |
* | |
* Requires that WP OAuth Server installed and activated. | |
* It can access using a valide access_token. | |
* | |
* POST/GET - Return JSON | |
* /oauth/hello?access_token=1234 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wo_endpoints','wo_extend_resource_api', 2); | |
function wo_extend_resource_api ($methods) | |
{ | |
$methods['me'] = array('func'=>'_wo_me'); | |
return $methods; | |
} | |
/** | |
* Replaces the default me enpoint | |
* @param [type] $token [description] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create cutom redirect validation hook | |
* | |
* NOTE: Since this is a filter the return should be a true or false but as a string. If 'true' is return the redirect_uri | |
* validation has passed. This example completely overides the redirect_uri validation. | |
* | |
* NOTE: This filter only runs during is a redirect_uri is given in th request | |
* | |
* Prioarity: 10 | |
* Number of Args: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Simple NSDefaults Wrapper | |
// | |
// Created by Justin Greer on 2/27/15. | |
// Copyright (c) 2015 Justin Greer Interactive, LLC. All rights reserved. | |
// | |
import Foundation | |
class FCStorage { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter('wo_endpoints','wo_extend_resource_api', 2); | |
function wo_extend_resource_api ($methods) | |
{ | |
$methods['me'] = array('func'=>'_wo_me'); | |
return $methods; | |
} | |
/** | |
* Replaces the default me enpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('wo_endpoints','new_hello_endpoint', 2); | |
function new_hello_endpoint ($methods){ | |
$methods['hello'] = array( | |
'func'=>'run_hello_method' // Function name to run | |
'public' => true|false // True to be public | |
); | |
return $methods; | |
} | |
function run_hello_method ($token){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Only allow 1 acces_token at a time | |
* @param [type] $results [description] | |
* @return [type] [description] | |
*/ | |
function test_only_allow_one_access_token ( $object ) { | |
if ( is_null( $object ) ) | |
return; | |
// Define the user ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wo_before_authorize_function_login_redirect( $request ){ | |
// Check if the user is logged in or not | |
if(!is_user_logged_in()){ | |
wp_redirect( 'http://your-custom-login.com/login' ); | |
exit; | |
} | |
// Else do nothing and let the server handle the request | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table width="100%" border="0" cellpadding="10" cellspacing="0"> | |
<tbody> | |
<tr bgcolor="#666"> | |
<th width="14%" valign="middle" bgcolor="#666" style="color: #FFF" scope="col">Header</th> | |
<th width="14%" valign="middle" bgcolor="#666" style="color: #FFF" scope="col">Header</th> | |
<th width="14%" valign="middle" bgcolor="#666" style="color: #FFF" scope="col">Header</th> | |
<th width="14%" valign="middle" bgcolor="#666" style="color: #FFF" scope="col">Header</th> | |
<th width="14%" valign="middle" bgcolor="#666" style="color: #FFF" scope="col">Header</th> | |
<th width="14%" valign="middle" bgcolor="#666" style="color: #FFF" scope="col">Header</th> | |
<th width="16%" valign="middle" bgcolor="#666" style="color: #FFF" scope="col">Header</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Simple Example of a client calling WordPress OAuth Server | |
* Replace the variabls below with your own. | |
* | |
* @author Justin Greer <[email protected]> | |
*/ | |
$server_url = 'https://wordpress.dev'; | |
$client_id = '6lkmsGocFcvxVG4S5s3QCHGi5Pvutl8AHtXaalmP'; | |
$client_secret = 'yRntyrmDTquw7bOd0kHuFQ5mj2wtnSjVKGpi8MW2'; |
OlderNewer