$where[] = "id NOT IN ({$this->_options['exclude_pages']})
AND parent NOT IN ({$this->_options['exclude_pages']}) ";
}
- $where[] = "active = true";
+ //$where[] = "active = true";
if (!empty($where)) {
$WHERE = ' WHERE ' . implode(' AND ', $where);
}
//echo '<pre>' . var_export($cMatch, true) . '</pre>';
for ($index = 0; $index < $captionCount; ++$index) {
//echo '<pre>cMatch: ' . print_r($cMatch[0][$index], true) . '</pre>';
- echo '<pre>'.htmlspecialchars($cMatch[0][$index]).'</pre>';
+ //echo '<pre>'.htmlspecialchars($cMatch[0][$index]).'</pre>';
//echo '<pre>Caption Match: ' . print_r($cMatch[1][$index], true) . '</pre>';
//echo '<pre>Caption Text: ' . print_r($cMatch[2][$index], true) . '/End Caption Text</pre>';
if (preg_match('%src="([^"]+)"%', $cMatch[0][$index], $srcMatch)) {
//echo '<pre>' . print_r($srcMatch, true) . '</pre>';
- echo '<pre>Sub Src Match: ' . print_r($srcMatch[1], true) . '</pre>';
+ //echo '<pre>Sub Src Match: ' . print_r($srcMatch[1], true) . '</pre>';
$fileInfo = pathinfo($srcMatch[1]);
$fileName = basename($srcMatch[1]);
$fileBaseName = $fileInfo['filename'];
- echo '<pre>File Info: ' . print_r($fileInfo, true) . '</pre>';
- echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
+ //echo '<pre>File Info: ' . print_r($fileInfo, true) . '</pre>';
+ //echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
$path = str_replace($fileName, '', $srcMatch[1]);
$path = $fileInfo['dirname'];
//echo '<pre>'.var_dump($path).'</pre>';
'src="' . $srcMatch[1] . '"',
'src="' . $newImage[0] . '" width="' . $newImage[1] . '" height="' . $newImage[1] . '"',
$cMatch[0][$index]);
- $caption = str_replace('<img', '<img class="wp-image-' . $imagesKey . ' size-medium"', $caption);
+ if (preg_match('%class="([^"]+)"%', $caption, $classMatch)) {
+ echo '<pre>First: '.print_r($classMatch).'</pre>';
+ echo '<p>Matching with preg_match</p>';
+ $caption = preg_replace('%class="([^"]+)"%', 'class="wp-image-' . $imagesKey . ' size-medium ' . $classMatch[1] . '"', $caption);
+ } else {
+ echo '<p>Matching with str_replace</p>';
+ $caption = str_replace('<img', '<img class="wp-image-' . $imagesKey . ' size-medium"', $caption);
+ }
+ //$caption = str_replace('<img', '<img class="wp-image-' . $imagesKey . ' size-medium"', $caption);
$caption = str_replace('[caption',
'[caption id="attachment_' . $imagesKey . '" width="' . $newImage[1] . '"',
$caption);
- echo '<pre>'.htmlspecialchars($caption).'</pre>';
+ echo '<pre>First: '.htmlspecialchars($caption).'</pre>';
$content = str_replace($cMatch[0][$index], $caption, $content);
}
}
if (preg_match_all('%<img ([^>]+)>%', $content, $matches)) {
$imageCount = count($matches[0]);
for ($index = 0; $index < $imageCount; ++$index) {
- echo '<pre>Image Match: ' . $imageCount . '</pre>';
- echo '<pre>'.htmlspecialchars($matches[0][$index]).'</pre>';
+ //echo '<pre>Image Match: ' . $imageCount . '</pre>';
+ //echo '<pre>'.htmlspecialchars($matches[0][$index]).'</pre>';
if (!(($uploads = wp_upload_dir()) && false === $uploads['error'])) {
return new WP_Error('upload_error', $uploads['error']);
}
- echo '<pre>Uploads Url: ' . print_r($uploads['url'], true) . '</pre>';
+ //echo '<pre>Uploads Url: ' . print_r($uploads['url'], true) . '</pre>';
if (preg_match('%src="' . $uploads['url'] . '[^"]+"%', $matches[1][$index], $pMatch)) {
continue;
}
if (preg_match('%src="([^"]+)"%', $matches[1][$index], $srcMatch)) {
- echo '<pre>Sub Src Match: ' . print_r($srcMatch[1], true) . '</pre>';
+ //echo '<pre>Sub Src Match: ' . print_r($srcMatch[1], true) . '</pre>';
$fileInfo = pathinfo($srcMatch[1]);
- echo '<pre>' . print_r($fileInfo, true) . '</pre>';
+ //echo '<pre>' . print_r($fileInfo, true) . '</pre>';
$fileName = $fileInfo['filename'];
- echo '<pre>File Url: ' . print_r($srcMatch[1], true) . '</pre>';
- echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
+ //echo '<pre>File Url: ' . print_r($srcMatch[1], true) . '</pre>';
+ //echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
$path = $filInfo['dirname'];
- echo '<pre>File Path: ' . print_r($path, true) . '</pre>';
+ //echo '<pre>File Path: ' . print_r($path, true) . '</pre>';
$imagesKey = $this->_getAttachmentByName($fileName);
var_dump($imagesKey);
if (!$imagesKey) {
// need to replace the src tags in content with the new image tags
$imageTag = str_replace($srcMatch[1], $newUrl, $matches[0][$index]);
if (preg_match('%class="([^"]+)"%', $matches[1][$index], $classMatch)) {
+ echo '<p>Matching with preg_match</p>';
$imageTag = preg_replace('%class="([^"]+)"%', 'class="wp-image-' . $imagesKey . ' size-medium $1"', $imageTag);
} else {
+ echo '<p>Matching with str_replace</p>';
$imageTag = str_replace('<img', '<img class="wp-image-' . $imagesKey . ' size-medium"', $imageTag);
}
//echo '<pre>'.htmlspecialchars($imageTag).'</pre>';
}
}
}
- //echo '<pre>'.htmlspecialchars($content).'</pre>';
+ echo '<pre>Second: '.htmlspecialchars($content).'</pre>';
echo '</div>';
$updatePost = array(
'ID' => $post->ID,
if (count($currentPostArray) > 0) {
echo '<p>Pages have been imported</p>';
echo '<p><a href="admin.php?import=toolbox&step=2">Step Two (Importing Images)</a></p>';
- echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Updating Image Ref)</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Importing Files)</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=4">Step Four (Updating Image Ref)</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=5">Step Five (Updating Files Ref)</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=6">Step Six (Updating Url\'s and keywords)</a></p>';
} else {
echo '<p><a href="admin.php?import=toolbox&step=1">Begin Import</a></p>';
}
break;
case 1:
echo '<p>Reset</p>';
- $this->_post = $this->_images = $this->_files = array();
- $this->_storePost();
- $this->_storeImages();
- $this->_storeFiles();
+ //$this->_post = $this->_images = $this->_files = array();
+ //$this->_storePost();
+ //$this->_storeImages();
+ //$this->_storeFiles();
$numPagesImported = $this->_import();
echo '<p>' . $numPagesImported . ' Pages Imported</p>';
echo '<p><a href="admin.php?import=toolbox&step=2">Step Two (Importing Images)</a></p>';
echo '<p>Now processing the images from old database tables</p>';
$this->_images = array();
$this->_storeImages();
- $this->_files = array();
- $this->_storeFiles();
if ($this->_options['toolbox_page_table'] == 'pages') {
$this->_getCkImages();
- $this->_getToolboxFiles();
$this->_getParagraphImages();
echo '<p>Done</p>';
} else {
$this->_getBusImages();
echo '<p>No import from images</p>';
}
- echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Updating Image Ref)</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=3">Step Three (Importing Files)</a></p>';
break;
case 3:
+ echo '<p>Done</p>';
+ echo '<p>Now processing the files from old database tables</p>';
+ $this->_files = array();
+ $this->_storeFiles();
+ if ($this->_options['toolbox_page_table'] == 'pages') {
+ $this->_getToolboxFiles();
+ echo '<p>Done</p>';
+ } else {
+ echo '<p>No import from images</p>';
+ }
+ echo '<p><a href="admin.php?import=toolbox&step=4">Step Four (Updating Image Ref)</a></p>';
+ break;
+ case 4:
echo '<p>Phase Three</p>';
$this->_updateMediaSrc();
echo '<p>Done</p>';
- echo '<p><a href="admin.php?import=toolbox&step=4">Step Four (Updating Files Ref)</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=5">Step Five (Updating Files Ref)</a></p>';
break;
- case 4:
- echo '<p>Phase Four</p>';
+ case 5:
+ echo '<p>Phase Five</p>';
echo '<p>Files</p>';
$this->_updateFilesHref();
echo '<p>Done</p>';
- echo '<p><a href="admin.php?import=toolbox&step=5">Step Five (Updating Url\'s and keywords)</a></p>';
+ echo '<p><a href="admin.php?import=toolbox&step=6">Step Six (Updating Url\'s and keywords)</a></p>';
break;
- case 5:
- echo '<p>Phase Five</p>';
+ case 6:
+ echo '<p>Phase Six</p>';
echo '<p>Site Url</p>';
// Replace the page Url's
$this->_replaceUrls();