function custom_posts_from_instagram() { $client_id = '7bb2aa2b9c3b4e679a6e9119034f55d1'; $user_id = '467550789'; // Get photos from Instagram $url = 'https://api.instagram.com/v1/users/' . $user_id . '/media/recent/?client_id=' . $client_id; $args = stream_context_create(array('http' => array('timeout' => 2500))); $json_feed = file_get_contents($url, false, $args); $json_feed = json_decode($json_feed); // Import each photo as post foreach ($json_feed->data as $post) { if (!slug_exists($post->id)) { $new_post = wp_insert_post(array('post_content' => '<a href="' . esc_url($post->link) . '" target="_blank"><img src="' . esc_url($post->images->standard_resolution->url) . '" alt="' . $post->caption->text . '" /></a>', 'post_date' => date("Y-m-d H:i:s", $post->created_time), 'post_date_gmt' => date("Y-m-d H:i:s", $post->created_time), 'post_status' => 'publish', 'post_title' => $post->id, 'post_name' => $post->id, 'post_category' => array(2)), true); } } function slug_exists($post_name) { global $wpdb; if ($wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $post_name . "'", 'ARRAY_A')) { return true; } else { return false; } } }
/** * @name add_slug * @todo Add Slug in database for pretty urls * @param STRING slug * @param INT object ID * @param STRING object type */ function add_slug($slug, $id, $type) { global $db; $counts = 0; $theSlug = $slug; while (1) { if (!slug_exists($theSlug, $type)) { break; } else { $counts++; $theSlug = $slug . '-' . $counts; } } $db->insert(tbl('slugs'), array('object_id', 'object_type', 'slug'), array($id, $type, $theSlug)); return array('id' => $db->insert_id(), 'slug' => $theSlug); }
| Copyright (c) 2007-2009 Clip-Bucket.com. All rights reserved. | @ Author : ArslanHassan | @ Software : ClipBucket , © PHPBucket.com ******************************************************************* */ define("THIS_PAGE", 'watch_video'); define("PARENT_PAGE", 'videos'); require 'includes/config.inc.php'; $userquery->perm_check('view_video', true); $pages->page_redir(); //Getting Video Key $vkey = @$_GET['v']; $slug = @$_GET['s']; $slug = mysql_clean($slug); if ($slug) { $slug = slug_exists($slug, 'v'); if ($slug) { $vkey = $slug['object_id']; } } else { $theslug = false; } $vdo = $cbvid->get_video($vkey, $theslug); assign('vdo', $vdo); assign('video', $vdo); if (video_playable($vdo)) { $pid = $_GET['play_list']; /** * Please check http://code.google.com/p/clipbucket/issues/detail?id=168 * for more details about following code */
/** * @todo check video slug exists or not * @name video_slug_exists * @author Arslan * @param STRNG slug */ function video_slug_exists($slug) { return slug_exists($slug, 'v'); }
INSERT INTO `pages` (`id` ,`title` ,`text` ,`seo_desc`) VALUES ('$id', '$title_bd', '$text_bd', '$seo_desc_bd') ON DUPLICATE KEY UPDATE `title`='$title_bd', `text`='$text_bd', `seo_desc` = '$seo_desc_bd' "; mysql_query($sql) or die(mysql_error()); /*SLUG*/ foreach ($languages as $chave => $lingua) { $sql = "DELETE FROM `slugs` WHERE id='$id' AND lg='$lingua'"; /*delete actual slugs*/ mysql_query($sql) or die(mysql_error()); if ($title[$lingua] == "") $title[$lingua] = 'no-name'; $slug = $slug_init = slug_gen($title[$lingua]); while (slug_exists($slug,$lingua)) { $e++;$slug = $slug_init."-".$e; } $sql = " INSERT INTO `slugs` (`id`,`lg` ,`slug`,`module`) VALUES ('$id', '$lingua', '$slug','page') ON DUPLICATE KEY UPDATE `slug`='$slug';\n "; $slug = $slug_init = ''; //echo $sql; mysql_query($sql) or die(mysql_error()); } $smarty->clearAllCache(); /*Clear smarty cache*/ }
* Author URI: http://www.cometton.com * License: GPL2 * */ //function custom_posts_from_instagram() { $access_token = '3258344245.0546445.fe333789a40848f8bb0bf3616edf1b0e'; $user_id = '3258344245'; // Get photos from Instagram $url = 'https://api.instagram.com/v1/users/' . $user_id . '/media/recent/?access_token=' . $access_token; $args = stream_context_create(array('http' => array('timeout' => 2500))); $json_feed = file_get_contents($url, false, $args); $json_feed = json_decode($json_feed); //echo '<pre>'; //print_r($json_feed); foreach ($json_feed->data as $post) { if (!slug_exists($post->id)) { $new_post = wp_insert_post(array('post_content' => '<a href="' . esc_url($post->link) . '" target="_blank"><img src="' . esc_url($post->images->standard_resolution->url) . '" alt="' . $post->caption->text . '" /></a>', 'post_date' => date("Y-m-d H:i:s", $post->created_time), 'post_date_gmt' => date("Y-m-d H:i:s", $post->created_time), 'post_status' => 'publish', 'post_title' => $post->id, 'post_name' => $post->id, 'post_category' => array(460)), true); insta_import_image($post->images->standard_resolution->url, $new_post); } } function slug_exists($post_name) { global $wpdb; if ($wpdb->get_row("SELECT post_name FROM wp_posts WHERE post_name = '" . $post_name . "'", 'ARRAY_A')) { return true; } else { return false; } } function insta_import_image($image_url, $post_id) {