diff --git a/wp-oauth-settings.php b/wp-oauth-settings.php index 0e34fa3..a7a0f05 100644 --- a/wp-oauth-settings.php +++ b/wp-oauth-settings.php @@ -44,7 +44,110 @@ function wpoa_cc_ux() { $points_max = 2; return floor(($points / $points_max) * 100); } - + + function wpoa_generate_login_section($provider) { + $section = $provider['section']; + $clientIDName = $provider['clientIDName']; + $clientSecretName = $provider['clientSecretName']; + $instructions = $provider['instructions']; + $references = $provider['references']; + $befores = $provider['befores']; + $afters = $provider['afters']; + + $section_hyphen = str_replace(' ', '-', str_replace('WP ', '', str_replace('.', '', strtolower($section)))); + $section_underscore = str_replace(' ', '_', str_replace('WP ', '', str_replace('.', '', strtolower($section)))); + + $template_instructions = ""; + foreach ($instructions as $instruction) { + $template_instructions .= "
  • ${instruction}
  • "; + } + + $template_befores = ""; + foreach ($befores as $before) { + $before_name = $before['name']; + $before_underscore = $before['name_underscore']; + $before_content = $before['content']; + $template_befores .= " + + ${before_name}: + + " + . ( + isset($before_content) ? + $before_content + : + "" + ) . + " + + + "; + } + + $template_afters = ""; + foreach ($afters as $after) { + $after_name = $after['name']; + $after_underscore = $after['name_underscore']; + $template_afters .= " + + ${after_name}: + + + + + "; + } + + $template = " + +
    +

    Login with ${section}

    +
    + + + + + + + ${template_befores} + + + + + + + + + + + + ${template_afters} + +
    Enabled: + +
    ${clientIDName}: + +
    ${clientSecretName}: + +
    +

    + Instructions: +

      + ${template_instructions} +
    + " + . (isset($references) ? $template_references : "") . + " +

    + " . get_submit_button('Save all settings') . " +
    +
    + + "; + + echo $template; + }; + // cache the config check ratings: $cc_security = wpoa_cc_security(); $cc_privacy = wpoa_cc_privacy(); @@ -486,486 +589,198 @@ function wpoa_cc_ux() { - - -
    -

    Login with Google

    -
    - - - - - - - - - - - - - - -
    Enabled: - /> -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    -

    - Instructions: -

      -
    1. Visit the Google website for developers console.developers.google.com.
    2. -
    3. At Google, create a new Project and enable the Google+ API. This will enable your site to access the Google+ API.
    4. -
    5. At Google, provide your site's homepage URL () for the new Project's Redirect URI. Don't forget the trailing slash!
    6. -
    7. At Google, you must also configure the Consent Screen with your Email Address and Product Name. This is what Google will display to users when they are asked to grant access to your site/app.
    8. -
    9. Paste your Client ID/Secret provided by Google into the fields above, then click the Save all settings button.
    10. -
    -

    - -
    -
    - + -
    -

    Login with WP OAuth Server

    -
    - - - - - - - - - - + wpoa_generate_login_section(array( + "section" => "Google", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "Visit the Google website for developers console.developers.google.com.", + "At Google, create a new Project and enable the Google+ API. This will enable your site to access the Google+ API.", + "At Google, provide your site's homepage URL (${blog_url}) for the new Project's Redirect URI. Don't forget the trailing slash!", + "At Google, you must also configure the Consent Screen with your Email Address and Product Name. This is what Google will display to users when they are asked to grant access to your site/app.", + "Paste your Client ID/Secret provided by Google into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array() + )); - - - - + wpoa_generate_login_section(array( + "section" => "WP OAuth Server", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "Log into the WordPress website that is running WP OAuth Server.", + "Go to OAuth Server and click on the "Clients" tab.", + "Click on "Add New Client" and follow the instructions.", + "Use ${blog_url} as the Redirect URI. Click "Add Client".", + "Provide a login provider name as the button text option above. Login with "My OAuth Server". This text will show on the login button.", + "Paste your Client ID/Secret provided by WP OAuth Server into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array( + array( + "name" => "OAuth Server Endpoint", + "name_underscore" => "endpoint" + ), + array( + "name" => "Login Button Text", + "name_underscore" => "button_text" + ) + ) + )); - - - - + wpoa_generate_login_section(array( + "section" => "Facebook", + "clientIDName" => "App ID", + "clientSecretName" => "App Secret", + "instructions" => array( + "Register as a Facebook Developer at developers.facebook.com.", + "At Facebook, create a new App. This will enable your site to access the Facebook API.", + "At Facebook, provide your site's homepage URL (${blog_url}) for the new App's Redirect URI. Don't forget the trailing slash!", + "Paste your App ID/Secret provided by Facebook into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array(), + )); - - - - -
    Enabled: - /> -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    OAuth Server Endpoint: - ' /> -
    Login Button Text: - ' /> -
    -

    - Instructions: -

      -
    1. Log into the WordPress website that is running WP OAuth Server.
    2. -
    3. Go to OAuth Server and click on the "Clients" tab.
    4. -
    5. Click on "Add New Client" and follow the instructions.
    6. -
    7. Use as the Redirect URI. Click "Add Client".
    8. -
    9. Provide a login provider name as the button text option above. Login with "My OAuth Server". This text will show on the login button.
    10. -
    11. Paste your Client ID/Secret provided by WP OAuth Server into the fields above, then click the Save all settings button.
    12. -
    -

    - -
    -
    - - - -
    -

    Login with Facebook

    -
    - - - - - - - - - - - - - - - -
    Enabled: - /> -
    App ID: - ' /> -
    App Secret: - ' /> -
    -

    - Instructions: -

      -
    1. Register as a Facebook Developer at developers.facebook.com.
    2. -
    3. At Facebook, create a new App. This will enable your site to access the Facebook API.
    4. -
    5. At Facebook, provide your site's homepage URL () for the new App's Redirect URI. Don't forget the trailing slash!
    6. -
    7. Paste your App ID/Secret provided by Facebook into the fields above, then click the Save all settings button.
    8. -
    -

    - -
    -
    - - - -
    -

    Login with LinkedIn

    -
    - - - - - - - - - - - - - - - -
    Enabled: - /> -
    API Key: - ' /> -
    Secret Key: - ' /> -
    -

    - Instructions: -

      -
    1. Register as a LinkedIn Developer at developers.linkedin.com.
    2. -
    3. At LinkedIn, create a new App. This will enable your site to access the LinkedIn API.
    4. -
    5. At LinkedIn, provide your site's homepage URL () for the new App's Redirect URI. Don't forget the trailing slash!
    6. -
    7. Paste your API Key/Secret provided by LinkedIn into the fields above, then click the Save all settings button.
    8. -
    -

    - -
    -
    - - - -
    -

    Login with Github

    -
    - - - - - - - - - - - - - - - -
    Enabled: - /> -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    -

    - Instructions: -

      -
    1. Register as a Github Developer at developers.github.com.
    2. -
    3. At Github, create a new App. This will enable your site to access the Github API.
    4. -
    5. At Github, provide your site's homepage URL () for the new App's Redirect URI. Don't forget the trailing slash!
    6. -
    7. Paste your API Key/Secret provided by Github into the fields above, then click the Save all settings button.
    8. -
    -

    - -
    -
    - + wpoa_generate_login_section(array( + "section" => "LinkedIn", + "clientIDName" => "API Key", + "clientSecretName" => "Secret Key", + "instructions" => array( + "Register as a LinkedIn Developer at developers.linkedin.com.", + "At LinkedIn, create a new App. This will enable your site to access the LinkedIn API.", + "At LinkedIn, provide your site's homepage URL (${blog_url}) for the new App's Redirect URI. Don't forget the trailing slash!", + "Paste your API Key/Secret provided by LinkedIn into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array(), + )); - -
    -

    Login with itembase

    -
    - - - - - + wpoa_generate_login_section(array( + "section" => "Github", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "Register as a Github Developer at developers.github.com.", + "At Github, create a new App. This will enable your site to access the Github API.", + "At Github, provide your site's homepage URL (${blog_url}) for the new App's Redirect URI. Don't forget the trailing slash!", + "Paste your API Key/Secret provided by Github into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array(), + )); - - - - + wpoa_generate_login_section(array( + "section" => "itembase", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "Register as an itembase Developer by following the instructions in the documentation.", + "Provide your site's homepage URL (${blog_url}) as redirect URI. Don't forget the trailing slash!", + "Paste your API Key/Secret provided by itembase into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array(), + )); - - - - -
    Enabled: - /> -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    -

    - Instructions: -

      -
    1. Register as an itembase Developer by following the instructions in the documentation.
    2. -
    3. Provide your site's homepage URL () as redirect URI. Don't forget the trailing slash!
    4. -
    5. Paste your API Key/Secret provided by itembase into the fields above, then click the Save all settings button.
    6. -
    -

    - -
    -
    - - - -
    -

    Login with Reddit

    -
    - - - - - - - - - - - - - - - -
    Enabled: - /> -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    -

    - Instructions: -

      -
    1. Register as a Reddit Developer at ssl.reddit.com/prefs/apps.
    2. -
    3. At Reddit, create a new App. This will enable your site to access the Reddit API.
    4. -
    5. At Reddit, provide your site's homepage URL () for the new App's Redirect URI. Don't forget the trailing slash!
    6. -
    7. Paste your Client ID/Secret provided by Reddit into the fields above, then click the Save all settings button.
    8. -
    -

    - -
    -
    - - - -
    -

    Login with Windows Live

    -
    - - - - - - - - - - - - - - - -
    Enabled: - /> -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    -

    - Instructions: -

      -
    1. Register as a Windows Live Developer at manage.dev.live.com.
    2. -
    3. At Windows Live, create a new App. This will enable your site to access the Windows Live API.
    4. -
    5. At Windows Live, provide your site's homepage URL () for the new App's Redirect URI. Don't forget the trailing slash!
    6. -
    7. Paste your Client ID/Secret provided by Windows Live into the fields above, then click the Save all settings button.
    8. -
    -

    - -
    -
    - + wpoa_generate_login_section(array( + "section" => "Reddit", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "Register as a Reddit Developer at ssl.reddit.com/prefs/apps.", + "At Reddit, create a new App. This will enable your site to access the Reddit API.", + "At Reddit, provide your site's homepage URL (${blog_url}) for the new App's Redirect URI. Don't forget the trailing slash!", + "Paste your Client ID/Secret provided by Reddit into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array(), + )); - -
    -

    Login with PayPal

    -
    - - - - - - - - - - - - - - - - - - - - -
    Enabled: - /> -
    Sandbox mode: - /> -

    PayPal offers a sandbox mode for developers who wish to setup and test PayPal Login with their site before going live.

    -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    -

    - Instructions: -

      -
    1. Register as a PayPal Developer at developer.paypal.com.
    2. -
    3. At PayPal, create a new App. This will enable your site to access the PayPal API. Your PayPal App will begin in sandbox mode for testing.
    4. -
    5. At PayPal, provide your site's homepage URL () for the App redirect URLs. Don't forget the trailing slash!
    6. -
    7. At PayPal, in the APP CAPABILITIES section, enable Log In with PayPal.
    8. -
    9. Paste your Client ID/Secret provided by PayPal into the fields above, then click the Save all settings button.
    10. -
    11. After testing PayPal login in sandbox mode with your site, you'll eventually want to switch the App over to live mode at PayPal, and turn off the Sandbox mode above.
    12. -
    -

    - -
    -
    - + wpoa_generate_login_section(array( + "section" => "Windows Live", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "Register as a Windows Live Developer at manage.dev.live.com.", + "At Windows Live, create a new App. This will enable your site to access the Windows Live API.", + "At Windows Live, provide your site's homepage URL (${blog_url}) for the new App's Redirect URI. Don't forget the trailing slash!", + "Paste your Client ID/Secret provided by Windows Live into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array(), + )); - -
    -

    Login with Instagram

    -
    - - - - - - - - - - - - - - - -
    Enabled: - /> -
    Client ID: - ' /> -
    Client Secret: - ' /> -
    -

    - Instructions: -

      -
    1. NOTE: Instagram's developer signup requires a valid cell phone number.
    2. -
    3. At Instagram, register as an Instagram Developer.
    4. -
    5. At Instagram, after signing up/in, click Manage Clients.
    6. -
    7. At Instagram, click Register a New Client. This will enable your site to access the Instagram API.
    8. -
    9. At Instagram, provide your site's homepage URL () for the OAuth redirect_uri. Don't forget the trailing slash!
    10. -
    11. At Instagram, copy the Client ID/Client Secret provided by Instagram and paste them into the fields above, then click the Save all settings button.
    12. -
    - References: - -

    - -
    -
    - + wpoa_generate_login_section(array( + "section" => "PayPal", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "Register as a PayPal Developer at developer.paypal.com.", + "At PayPal, create a new App. This will enable your site to access the PayPal API. Your PayPal App will begin in sandbox mode for testing.", + "At PayPal, provide your site's homepage URL (${blog_url}) for the App redirect URLs. Don't forget the trailing slash!", + "At PayPal, in the APP CAPABILITIES section, enable Log In with PayPal.", + "Paste your Client ID/Secret provided by PayPal into the fields above, then click the Save all settings button.", + "After testing PayPal login in sandbox mode with your site, you'll eventually want to switch the App over to live mode at PayPal, and turn off the Sandbox mode above." + ), + "befores" => array( + array( + "name" => "Sandbox mode", + "content" => " + +

    PayPal offers a sandbox mode for developers who wish to setup and test PayPal Login with their site before going live.

    + " + ) + ), + "afters" => array(), + )); - -
    -

    Login with Battle.net

    -
    - - - - - - - - - - - - - - - -
    Enabled: - /> -
    Key: - ' /> -
    Secret: - ' /> -
    - -

    - Instructions: -

      -
    1. NOTE: Battle.net API requires your site to be secured with an SSL certificate; the site URL should start with https://.
    2. -
    3. Visit the Battle.net API home page and Create a Mashery Account. -
    4. After creating your account and signing in, visit the My Applications page.
    5. -
    6. Create a New Application and fill out the details.
    7. -
    8. Provide your site URL (/) for the Register Callback URL. Don't forget the trailing slash!
    9. -
    10. After registering the application, locate the Key/Secret provided by Battle.net and paste them into the fields above, then click the Save all settings button.
    11. -
    - References: - -

    - -
    -
    - + wpoa_generate_login_section(array( + "section" => "Instagram", + "clientIDName" => "Client ID", + "clientSecretName" => "Client Secret", + "instructions" => array( + "NOTE: Instagram's developer signup requires a valid cell phone number.", + "At Instagram, register as an Instagram Developer.", + "At Instagram, after signing up/in, click Manage Clients.", + "At Instagram, click Register a New Client. This will enable your site to access the Instagram API.", + "At Instagram, provide your site's homepage URL (${blog_url}) for the OAuth redirect_uri. Don't forget the trailing slash!", + "At Instagram, copy the Client ID/Client Secret provided by Instagram and paste them into the fields above, then click the Save all settings button." + ), + "befores" => array(), + "afters" => array(), + )); + + wpoa_generate_login_section(array( + "section" => "Battle.net", + "clientIDName" => "Key", + "clientSecretName" => "Secret", + "instructions" => array( + "NOTE: Battle.net API requires your site to be secured with an SSL certificate; the site URL should start with https://.", + "Visit the Battle.net API home page and Create a Mashery Account.", + "After creating your account and signing in, visit the My Applications page.", + "Create a New Application and fill out the details.", + "Provide your site URL (/) for the Register Callback URL. Don't forget the trailing slash!", + "After registering the application, locate the Key/Secret provided by Battle.net and paste them into the fields above, then click the Save all settings button." + ), + "references" => array( + "Battle.net OAuth Reference", + "Battle.net API Terms of Service" + ), + "befores" => array(), + "afters" => array(), + )); +?>