function dg_tw_publish_mega_tweet($tweets) { global $dg_tw_queryes, $dg_tw_publish, $dg_tw_tags, $dg_tw_cats, $dg_tw_ft, $wpdb; $content = '<ul id="dg_tw_list_tweets">'; foreach ($tweets as $tweet) { if (!dg_tw_iswhite($tweet)) { continue; } $str = dg_tw_regexText($tweet['text']); $str = preg_replace("/(?<!a href=\")(?<!src=\")((http|ftp)+(s)?:\\/\\/[^<>\\s]+)/i", "<a href=\"\\0\" target=\"_blank\">\\0</a>", $str); $str = preg_replace('|@(\\w+)|', '<a href="http://twitter.com/$1" target="_blank">@$1</a>', $str); $str = preg_replace('|#(\\w+)|', '<a href="http://twitter.com/search?q=%23$1" target="_blank">#$1</a>', $str); $time_tweet = !empty($dg_tw_ft['tweettime']) ? ' - ' . date('Y-m-d H:i:s', strtotime($tweet['created_at'])) : ''; $content .= '<li class="single_tweet">' . $str . $time_tweet . '</li>'; } $content .= '</ul>'; $tweet_title = empty($dg_tw_ft['title_format']) ? "Periodically tweets" : $dg_tw_ft['title_format']; $post = array('post_author' => $dg_tw_ft['author'], 'post_content' => $content, 'post_name' => dg_tw_slug($tweet_title), 'post_status' => strval($dg_tw_publish), 'post_title' => $tweet_title, 'post_category' => $dg_tw_cats, 'tags_input' => $dg_tw_tags, 'post_type' => 'post', 'post_status' => strval($dg_tw_publish)); $dg_tw_this_post = wp_insert_post($post, true); return 'true'; }
<th scope="col" style="width: 10%;"> <span>Publish</span> </th> </thead> <tbody id="the-list"> <?php foreach ($dg_tw_data->statuses as $item) { if (isset($dg_tw_ft['exclude_retweets']) && $dg_tw_ft['exclude_retweets'] && isset($item->retweeted_status)) { continue; } if (isset($dg_tw_ft['exclude_no_images']) && $dg_tw_ft['exclude_no_images'] && !count($item->entities->media)) { continue; } if (dg_tw_iswhite($item)) { $content = dg_tw_regexText($item->text); ?> <tr id="post-190" class="post-190 type-post status-publish format-standard hentry alternate iedit author-self" valign="top"> <td scope="row" style="width:55px;text-align:center;" align="center"> <?php if (isset($item->entities->media)) { foreach ($item->entities->media as $media) { if ($media->type == "photo") { echo '<img style="max-height:50px;max-width:50px;" src="' . $media->media_url . '" alt=""/>'; break; } } } ?> </td> <td scope="row">
function dg_tw_publish_mega_tweet($tweets) { global $dg_tw_queryes, $dg_tw_publish, $dg_tw_tags, $dg_tw_cats, $dg_tw_ft, $wpdb; $content = '<ul id="dg_tw_list_tweets">'; foreach ($tweets as $tweet) { if (!dg_tw_iswhite($tweet)) { continue; } $str = dg_tw_regexText($tweet['text']); $str = preg_replace("/(?<!a href=\")(?<!src=\")((http|ftp)+(s)?:\\/\\/[^<>\\s]+)/i", "<a href=\"\\0\" target=\"_blank\">\\0</a>", $str); $str = preg_replace('|@(\\w+)|', '<a href="http://twitter.com/$1" target="_blank">@$1</a>', $str); $str = preg_replace('|#(\\w+)|', '<a href="http://twitter.com/search?q=%23$1" target="_blank">#$1</a>', $str); $time_tweet = !empty($dg_tw_ft['tweettime']) ? ' - ' . date('Y-m-d H:i:s', strtotime($tweet['created_at'])) : ''; $content .= '<li class="single_tweet">' . $str . $time_tweet . '</li>'; } $content .= '</ul>'; $tweet_title = empty($dg_tw_ft['title_format']) ? "Periodically tweets" : $dg_tw_ft['title_format']; $post = array('post_author' => $dg_tw_ft['author'], 'post_content' => $content, 'post_name' => dg_tw_slug($tweet_title), 'post_status' => strval($dg_tw_publish), 'post_title' => $tweet_title, 'tags_input' => $dg_tw_tags, 'post_type' => 'post', 'post_status' => strval($dg_tw_publish)); $dg_tw_this_post = wp_insert_post($post, true); $tags = wp_get_post_tags($dg_tw_this_post); foreach ($tags as $tag) { switch ($tag->name) { case "SafetyDataGov": $category_id = get_cat_ID("safety"); break; case "usdatagov": $category_id = get_cat_ID("developers"); break; case "HealthDataGov": $category_id = get_cat_ID("health"); break; case "energydatagov": $category_id = get_cat_ID("energy"); break; default: $category_id = ""; } } wp_set_post_categories($dg_tw_this_post, array($category_id)); if ($dg_tw_this_post) { // adding acf values $username = dg_tw_tweet_user($tweet); $tweet_url = 'https://twitter.com/' . $username . '/status/' . $tweet->id_str; update_field("field_5176000e6c97e", $username, $dg_tw_this_post); update_field("field_517600256c97f", $username, $dg_tw_this_post); update_field("field_517600346c980", $tweet->user->profile_image_url_https, $dg_tw_this_post); update_field("field_517600586c981", $tweet_url, $dg_tw_this_post); } return 'true'; }