0,
$rootUrl . '/'
);
- $image = wp_get_attachment_image_src($img_id, 'full');
+ $image = wp_get_attachment_image_src($img_id, 'medium');
return $image[0];
}
$where[] = "(id = {$this->_options['include_pages']}"
. " OR id IN (" . implode(',', $subPageIds) . ") )";
} else {
- $where[] = "id = {$this->_options['include_pages']}";
- }
+ $where[] = "id = {$this->_options['include_pages']}";
+ }
} else {
$where[] = "id IN ({$this->_options['include_pages']})";
{
$this->_connect();
if ($this->_options['toolbox_page_table'] == 'pages') {
- $sql = "
- SELECT navigation_name
- FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_page_table']}
- WHERE id = :id";
- } else {
- $sql = "
- SELECT category as navigation_name
- FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_page_table']}
- WHERE id = :id";
- }
+ $sql = "
+ SELECT navigation_name
+ FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_page_table']}
+ WHERE id = :id";
+ } else {
+ $sql = "
+ SELECT category as navigation_name
+ FROM {$this->_options['toolbox_schema']}.{$this->_options['toolbox_page_table']}
+ WHERE id = :id";
+ }
$stmt = $this->_dbh->prepare($sql);
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
$stmt->execute();
}
}
+ private function replaceIsoUrls()
+ {
+ global $wpdb;
+ $this->_connect();
+ echo '<p>Replace IS0 url\'s</p>';
+ $searchUrl = 'http://is0.gaslightmedia.com';
+ // find all pages with links to site pages
+ $sql = "
+ SELECT *
+ FROM {$wpdb->prefix}posts
+ WHERE post_content LIKE '%{$searchUrl}%'
+ AND post_type = 'page'";
+ echo '<pre>'.$sql.'</pre>';
+ $results = $wpdb->get_results($sql, OBJECT);
+ if (count($results) > 0) {
+ //echo '<pre>' . print_r($results, true) . '</pre>';
+ $pattern = ';(http://is0.gaslightmedia.com/[^"]+);si';
+ foreach ($results as $post) {
+ $content = $post->post_content;
+ preg_match_all($pattern, $post->post_content, $matches);
+ $matches = array_unique($matches[0]);
+ echo '<pre>' . print_r($post->ID, true) . '</pre>';
+ echo '<pre>' . print_r($matches, true) . '</pre>';
+ foreach ($matches as $match) {
+ // process the file as media library
+ $parsed = parse_url($match);
+ $filename = basename($parsed['path']);
+ $rootUrl = str_replace('/' . $filename, '', $match);
+ echo '<pre>' . print_r($parsed, true) . '</pre>';
+ echo '<pre>' . print_r($filename, true) . '</pre>';
+ echo '<pre>' . print_r($rootUrl, true) . '</pre>';
+ $img_id = $this->_handleMediaFile(
+ basename($parsed['path']),
+ '',
+ $post->ID,
+ $rootUrl . '/'
+ );
+ echo '<pre>' . print_r($img_id, true) . '</pre>';
+ $replaceUrl = wp_get_attachment_url($img_id);
+ echo '<pre>' . print_r($image, true) . '</pre>';
+ $content = str_replace($match, $replaceUrl, $content);
+ }
+ $updatePost = array(
+ 'ID' => $post->ID,
+ 'post_content' => $content
+ );
+ wp_update_post($updatePost);
+ }
+ }
+ }
+
/**
* dispatch
*
echo '<p><a href="admin.php?import=toolbox&step=2">Part 2</a></p>';
break;
case 2:
- $this->_replaceKeywords();
- echo '<p><a href="admin.php?import=toolbox&step=3">Part 3</a></p>';
+ //$this->_replaceKeywords();
+ $this->replaceIsoUrls();
+ echo '<p>Done</p>';
+ //echo '<p><a href="admin.php?import=toolbox&step=3">Part 3</a></p>';
break;
case 3:
$this->_replaceUrls();