$service) { foreach ($service['result_urls'] as $result_url) { $query = "select * from " . $wpdb->prefix . "auphonic_importer where filename = '" . $result_url . "'"; $results = $wpdb->get_row( $query ); if ($results === null){ if (stristr($result_url, ".m")) { $enclosure = $result_url . "\n"; $enclosure .= $production['output_files'][$key]['size'] . "\n"; $enclosure .= "audio/mpeg"; } } } if (isset($enclosure)) { break; } } if (isset($enclosure)) { $post = array( 'post_title' => $production['metadata']['title'], 'post_content' => $production['metadata']['summary'], 'post_status' => $status, 'post_type' => 'post', 'post_author' => $user, 'post_parent' => 0, 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0 ); $post_ID = wp_insert_post($post, $wp_error); wp_set_post_terms($post_ID, array($category), 'category'); update_post_meta($post_ID, "enclosure", $enclosure); if ($tags) { if ($remove_tag) { $tags = array_diff($tags, array($tag)); } wp_set_post_tags($post_ID, $tags); } /* Log Each new Enclosure */ $query = "insert into " . $wpdb->prefix . "auphonic_importer set filename = '" . $result_url . "'"; $wpdb->query($query); } unset($enclosure, $url); } } } } update_option("ai_lastUpdated", date("Y-m-d H:i:s", mktime() - 14400)); } } } /* adding Menu for Option */ add_action('admin_menu', 'ai_admin_menu'); function ai_admin_menu() { $page_title = 'Auphonic Importer Admin Settings'; $menu_title = 'Auphonic Importer'; $capability = 'manage_options'; $menu_slug = 'ai-settings'; $function = 'ai_settings'; add_options_page($page_title, $menu_title, $capability, $menu_slug, $function); } function ai_settings() { if (!current_user_can('manage_options')) { wp_die('You do not have sufficient permissions to access this page.'); } $options = get_option("ai_options"); if ($options['ai_initialized'] != "yes") { include( plugin_dir_path(__FILE__) . 'init.php'); } else { include( plugin_dir_path(__FILE__) . 'settings.php'); } } if (isset($_POST['ai_save_options'])) { $options = array("ai_username" => $_POST['ai_username'], "ai_password" => $_POST['ai_password'], "ai_tag" => $_POST['ai_tag'], "ai_remove_tag" => $_POST['ai_remove_tag'], "ai_enabled" => $_POST['ai_enabled'], "ai_category" => $_POST['ai_category'], "ai_user" => $_POST['ai_user'], "ai_initialized" => "yes", "ai_status" => $_POST['ai_status'], "ai_update_password" => $_POST['ai_update_password']); update_option("ai_options", $options); } if (isset($_POST['ai_init'])) { global $wpdb; $table_name = $wpdb->prefix . "auphonic_importer"; $sql = "CREATE TABLE IF NOT EXISTS `{$table_name}` ( `production_ID` int(11) NOT NULL AUTO_INCREMENT, `filename` text NOT NULL, `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, UNIQUE KEY `production_ID` (`production_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 "; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta($sql); $options = array("ai_username" => "", "ai_password" => "", "ai_tag" => "", "ai_enabled" => "", "ai_category" => "", "ai_user" => "", "ai_initialized" => "yes", "ai_status" => "", "ai_update_password" => "yes"); update_option("ai_options", $options); } if (isset($_GET['ai_clear_cache'])) { global $wpdb; $table_name = $wpdb->prefix . "auphonic_importer"; $wpdb->query("truncate table " . $table_name); } function ai_show($data) { print "
";
    print_r($data);
    print "
"; }