Exemplo n.º 1
0
     if (!$playerSettings_clean || empty($playerSettings_clean)) {
         //malformed data
         $error = true;
         $msg = 'Something wrong with player input settings, please try again.';
     } elseif (is_array($playerSettings_clean)) {
         //looks good update options
         foreach ($playerSettings_clean as $key => $val) {
             update_option('libsyn-podcasting-' . $key, $val);
         }
     }
 } elseif ($_POST['submit'] === 'Save Changes') {
     //has config changes or update
     if (isset($_POST['showSelect'])) {
         $api->setShowId($_POST['showSelect']);
     }
     if ($api->getClientSecret() !== $sanitize->clientSecret($_POST['clientSecret'])) {
         $api->setClientSecret($sanitize->clientSecret($_POST['clientSecret']));
     }
     if ($api->getClientId() !== $sanitize->clientId($_POST['clientId'])) {
         $api->setClientId($sanitize->clientId($_POST['clientId']));
     }
     if (!isset($_POST['feed_redirect_url'])) {
         $_POST['feed_redirect_url'] = '';
     }
     if ($api->getFeedRedirectUrl() !== $_POST['feed_redirect_url']) {
         $api->setFeedRedirectUrl($_POST['feed_redirect_url']);
     }
     $update = $plugin->updateSettings($api);
     if ($update !== false) {
         $msg = "Settings Updated";
     }
Exemplo n.º 2
0
 /**
  * Create new Libsyn-WP Api
  * 
  * @param <array> $settings 
  * 
  * @return <Libsyn\Api>
  */
 public function createLibsynApi(array $settings)
 {
     global $wpdb;
     /*
      * We'll set the default character set and collation for this table.
      * If we don't do this, some characters could end up being converted 
      * to just ?'s when saved in our table.
      */
     $charset_collate = '';
     if (!empty($wpdb->charset)) {
         $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
     }
     if (!empty($wpdb->collate)) {
         $charset_collate .= " COLLATE {$wpdb->collate}";
     }
     $sql = "CREATE TABLE {$this->api_table_name} (\r\n\t\t  plugin_api_id mediumint(9) NOT NULL AUTO_INCREMENT,\r\n\t\t  client_id varchar(64) NOT NULL,\r\n\t\t  client_secret varchar(80) NOT NULL,\r\n\t\t  access_token varchar(40) NOT NULL,\r\n\t\t  refresh_token varchar(40) NOT NULL,\r\n\t\t  is_active tinyint(3) DEFAULT 0 NOT NULL,\r\n\t\t  refresh_token_expires DATETIME DEFAULT '0000-00-00 00:00:00' NOT NULL,\r\n\t\t  access_token_expires datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,\r\n\t\t  show_id int(8),\r\n\t\t  feed_redirect_url varchar(510),\r\n\t\t  itunes_subscription_url varchar(510),\r\n\t\t  creation_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,\r\n\t\t  last_updated timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n\t\t  UNIQUE KEY id (plugin_api_id)\r\n\t\t) {$charset_collate};";
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     dbDelta($sql);
     //Sanitize Data
     $sanitize = new \Libsyn\Service\Sanitize();
     //insert $settings
     $wpdb->insert($this->api_table_name, array('client_id' => $sanitize->clientId($settings['client_id']), 'client_secret' => $sanitize->clientSecret($settings['client_secret']), 'access_token' => $sanitize->accessToken($settings['access_token']), 'refresh_token' => $sanitize->refreshToken($settings['refresh_token']), 'is_active' => 1, 'refresh_token_expires' => $sanitize->date_format(date("Y-m-d H:i:s", strtotime("+60 days", strtotime(current_time('mysql'))))), 'access_token_expires' => $sanitize->date_format(date("Y-m-d H:i:s", strtotime("+1 hour", strtotime(current_time('mysql'))))), 'creation_date' => $sanitize->date_format(current_time('mysql'))));
     $lastId = $wpdb->insert_id;
     $data = $wpdb->get_results("SELECT * FROM {$this->api_table_name} WHERE plugin_api_id = {$lastId} AND is_active = 1");
     return new \Libsyn\Api($data[0]);
 }