Exemplo n.º 1
0
function displaySCUSettings()
{
    //TODO - form validation for track info
    $errors = '';
    $sc_client_id = '';
    $sc_client_secret = '';
    $soundcloud_access_token = '';
    $sc_redirect_uri = site_url() . '/wp-admin/admin.php?page=wpshq_scu_plugin_options';
    $sc_comments = '';
    $sc_visibility = '';
    $sc_genre = '';
    $sc_track_desc = '';
    $sc_track_title = '';
    $attached_file = '';
    if (isset($_POST['soundcloud_clear'])) {
        //add the data to the wp_options table
        $options = array('sc_client_id' => '', 'sc_client_secret' => '', 'sc_client_access_token' => '', 'sc_redirect_uri' => '');
        update_option('soundcloud_settings', $options);
        //store the results in WP options table
        echo '<div id="message" class="updated fade">';
        echo '<p>Settings Cleared</p>';
        echo '</div>';
    } else {
        if (isset($_POST['soundcloud_update'])) {
            if ($_POST['sc-client-id'] != "") {
                $sc_client_id = filter_var($_POST['sc-client-id'], FILTER_SANITIZE_STRING);
                if ($_POST['sc-client-id'] == "") {
                    $errors .= 'Please enter a valid SoundCloud ID.<br/><br/>';
                }
            } else {
                $errors .= 'Please enter your SoundCloud ID.<br/>';
            }
            if ($_POST['sc-client-secret'] != "") {
                $sc_client_secret = filter_var($_POST['sc-client-secret'], FILTER_SANITIZE_STRING);
                if ($_POST['sc-client-secret'] == "") {
                    $errors .= 'Please enter a valid SoundCloud secret.<br/>';
                }
            } else {
                $errors .= 'Please enter your SoundCloud secret string.<br/>';
            }
            if (!$errors) {
                //add the data to the wp_options table
                $options = array('sc_client_id' => $sc_client_id, 'sc_client_secret' => $sc_client_secret, 'sc_client_access_token' => $soundcloud_access_token, 'sc_redirect_uri' => $sc_redirect_uri);
                update_option('soundcloud_settings', $options);
                //store the results in WP options table
                echo '<div id="message" class="updated fade">';
                echo '<p>Settings Saved</p>';
                echo '</div>';
            } else {
                echo '<div class="error fade">' . $errors . '<br/></div>';
            }
            //now let's authenticate and grab the token
            //wp_scu_authenticate();
        }
    }
    $sc_settings = get_option('soundcloud_settings');
    $sc_client_id = $sc_settings['sc_client_id'];
    $sc_client_secret = $sc_settings['sc_client_secret'];
    $soundcloud_access_token = $sc_settings['sc_client_access_token'];
    //	if ($soundcloud_access_token == '') {
    //		echo '<div class="error fade">The connection to the SoundCloud API needs to be authorized.
    //		Please enter your settings and click the "Save" button to authorize the connection.<br/></div>';
    //	}
    ?>

<div class="wrap">
<div id="poststuff"><div id="post-body">
<div class="postbox">
<h3><label for="title">Before Using This Plugin</label></h3>
<div class="inside">
<p class="postbox-container">To use the WP SoundCloud Ultimate plugin you will firstly need to create a SoundCloud app using your current SoundCloud account details and then paste some
of the details from your app in the configuration settings of this page.
<br /> 
<h2>Creating Your SoundCloud App</h2>
This literally takes a minute to do. To create a SoundCloud app go to <a href="http://soundcloud.com/you/apps" target="_blank">THIS PAGE</a> and fill in the details as follows:
<ol>
	<li type="disc">
		Enter the following string for the name of your app - <strong>soundcloud-ultimate-plugin</strong></li>
	<li type="disc">
		Then click the register button and enter the following details in the app form:
		<ol>
		<li type="disc"><strong>Website of your app</strong> - Enter your own website URL</li>
		<li type="disc"><strong>Redirect URI for Authentication</strong> - Copy and paste the following url - <span style="color: green; background-color:yellow;"><strong><?php 
    echo site_url();
    ?>
/wp-admin/admin.php?page=wpshq_scu_plugin_options</strong></span></li>
		</ol>
	</li>
</ol>
<h2>Configuring the Plugin</h2>
After creating the app, copy the following details from your app and paste in the configuration settings on this page:
<ol>
	<li type="disc"><strong>Sound Cloud Client ID</strong> - Copy this value from your SoundCloud app and paste in the field below.</li>
	<li type="disc"><strong>Sound Cloud Client Secret</strong> - Copy this value from your SoundCloud app and paste in the field below.</li>
</ol>
After entering the configuration settings click the "Save Settings" button.
<h2>Connecting To SoundCloud</h2>
After saving your settings click the "<strong>Connect To Soundcloud</strong>" link in the "SoundCloud Connection Status" section below.
This will take you to the SoundCloud site and ask you to allow the "soundcloud-ultimate-plugin" to connect to your SoundCloud account.
Click the "Connect" button.
</p>
</div></div>
<div class="postbox">
<h3><label for="title">SoundCloud Connection Status</label></h3>
<div class="inside  scu_connect_status">
<?php 
    if ($sc_client_id && $sc_client_secret && !$soundcloud_access_token) {
        echo '<div class="scu_error_msg" style="color:red;"><strong>You are currently disconnected from SoundCloud.</strong></div>';
        ?>

<?php 
        wp_scu_authenticate();
        ?>
</p>
<?php 
    } else {
        if (!$sc_client_id && !$sc_client_secret) {
            echo '<div class="scu_error_msg" style="color:red;"><strong>You are currently disconnected from SoundCloud.</strong></div>';
        } else {
            echo '<div class="scu_success_msg" style="color:green;"><strong>You are currently connected to SoundCloud.</strong></div>';
        }
    }
    ?>
</div></div>
<form action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
" method="POST"	onsubmit="">
<input type="hidden" name="soundcloud_update" id="soundcloud_update" value="true" />
<div class="postbox">
<h3><label for="title">Enter Your SoundCloud Account Details</label></h3>
<div class="inside">
<table class="form-table">
	<tr valign="top">
		<th scope="row"><label for="SCClientID"> Enter Your SoundCloud Client ID:</label>
		</th>
		<td><input type="text" size="40" name="sc-client-id" value="<?php 
    echo $sc_client_id;
    ?>
" /></td>
	</tr>
	<tr valign="top">
		<th scope="row"><label for="SCClientID"> Enter Your SoundCloud Client Secret:</label>
		</th>
		<td><input type="text" size="40" name="sc-client-secret" value="<?php 
    echo $sc_client_secret;
    ?>
" /></td>
	</tr>
</table>
<input name="soundcloud_update" type="submit" value="Save Settings" class="button-primary" />
<input name="soundcloud_clear" type="submit" value="Clear Settings" class="button-primary" />
	</div></div>
<br />
	</form>
</div></div>
</div>
<?php 
}
Exemplo n.º 2
0
function soundcloud_plugin_options()
{
    ?>
    <div class="wrap">
      <?php 
    screen_icon();
    ?>
      <h2>Soundcloud Configuration</h2>

<div id="poststuff"><div id="post-body">
<div class="postbox">
<div class="inside">
<p class="postbox-container">
<h2>Creating Your SoundCloud App</h2>
 To create a SoundCloud app go to <a href="http://soundcloud.com/you/apps" target="_blank">THIS PAGE</a> and fill in the details as follows:
<ol>
  <li type="disc">
    Enter the following string for the name of your app - <strong>Soundcloud plugin</strong></li>
  <li type="disc">
    Then click the register button and enter the following details in the app form:
    <ol>
    <li type="disc"><strong>Website of your app</strong> - Enter your own website URL</li>
    <li type="disc"><strong>Redirect URI for Authentication</strong> - Copy and paste the following url - <span style="color: green; background-color:yellow;"><strong><?php 
    echo site_url();
    ?>
/wp-admin/admin.php?page=sound</strong></span></li>
    </ol>
  </li>
</ol>
</p>

<h2>Enter Your SoundCloud Details</h2>


        <form action="options.php" method="post">
             <?php 
    settings_fields('soundcloud-group');
    ?>
             <?php 
    @do_settings_fields('soundcloud-group');
    ?>
             <table class="form-table">
                <tr valign="top">
                    <th scope="row">
                        <label for="soundcloud_client_id">SoundCloud Client ID:</label>
                    </th>
                    <td>
                        <input type="text" size="40" name="soundcloud_client_id" id="soundcloud_client_id" value="<?php 
    echo get_option('soundcloud_client_id');
    ?>
">
                    </td>
                </tr>
                     <tr valign="top">
                    <th scope="row">
                        <label for="soundcloud_client_secret">SoundCloud Client Secret:</label>
                    </th>
                    <td>
                        <input type="text" size="40" name="soundcloud_client_secret" id="soundcloud_client_secret" value="<?php 
    echo get_option('soundcloud_client_secret');
    ?>
">
                    </td>
                </tr>
                 <tr valign="top">
                    <th scope="row">
                        <label for="soundcloud_redirect_uri'">SoundCloud Redirect  URI:</label>
                    </th>
                    <td>
                        <input type="text" size="40" name="soundcloud_redirect_uri" id="soundcloud_redirect_uri" value="<?php 
    echo site_url() . '/wp-admin/admin.php?page=sound';
    ?>
">
                    </td>
                </tr>
             </table>
             <?php 
    @submit_button();
    ?>
            </form>
       </div>
       <div class="postbox">
<h3><label for="title">SoundCloud Connection Status</label></h3>
<div class="inside  scu_connect_status">
<?php 
    $sc_client_id = get_option('soundcloud_client_id');
    $sc_client_secret = get_option('soundcloud_client_secret');
    $redirect_uri = get_option('soundcloud_redirect_uri');
    if ($sc_client_id && $sc_client_secret && !$soundcloud_access_token) {
        echo '<div class="scu_error_msg" style="color:red;"><strong>You are currently disconnected from SoundCloud.</strong></div>';
        ?>

<?php 
        wp_scu_authenticate();
        ?>
</p>
<?php 
    } else {
        if (!$sc_client_id && !$sc_client_secret) {
            echo '<div class="scu_error_msg" style="color:red;"><strong>You are currently disconnected from SoundCloud.</strong></div>';
        } else {
            echo '<div class="scu_success_msg" style="color:green;"><strong>You are currently connected to SoundCloud.</strong></div>';
        }
    }
    ?>
</div></div>
   </div>
  </div>
    <?php 
}