global $wpdb;
$currentPostArray = get_option(GLM_WP_IMPORT_POST_OPTION, array());
$files = get_option(GLM_WP_IMPORT_FILES_OPTION, array());
- echo '<pre>' . print_r($files, true) . '</pre>';
+ //echo '<pre>' . print_r($files, true) . '</pre>';
//$images = get_option(GLM_WP_IMPORT_IMAGES_OPTION, array());
//$media = array_merge($images, $files);
//echo '<pre>' . print_r($media, true) . '</pre>';
foreach ($results as $post) {
$content = $post->post_content;
echo '<div style="border: 1px solid green; padding: 9px; margin: 10px;">';
- $urlPattern = '%<a href="(' . $this->_options['toolbox_files_url'] . '/[^">]*)" ?[^>]*>([^>]+)</a>%s';
+ $urlPattern = '%<a href="(' . $this->_options['toolbox_files_url'] . '/[^"]+)"%si';
+ echo '<pre>$urlPattern: ' . htmlspecialchars( $urlPattern ) . '</pre>';
if (preg_match_all($urlPattern, $content, $isMatch)) {
$isMatchCount = count($isMatch[0]);
- echo '<p>Matches is0 ' . $isMatchCount . '</p>';
+ echo '<p>Matches file url ' . $isMatchCount . '</p>';
for ($index = 0; $index < $isMatchCount; ++$index) {
echo '<pre>'.htmlspecialchars($isMatch[1][$index]).'</pre>';
//echo '<pre>'.htmlspecialchars(basename($isMatch[1][$index])).'</pre>';
$fileInfo = pathinfo($isMatch[1][$index]);
$fileName = $fileInfo['filename'];
echo '<pre>File Name: ' . print_r($fileName, true) . '</pre>';
- echo '<pre>File Name: ' . print_r($fileInfo, true) . '</pre>';
- $fileTitle = $isMatch[2][$index];
- echo '<pre>File Title: ' . print_r($fileTitle, true) . '</pre>';
+ echo '<pre>File Info: ' . print_r($fileInfo, true) . '</pre>';
$key = $this->_getAttachmentByName($fileName);
echo '<pre>Key: ' . print_r($key, true) . '</pre>';
// check on format of filename
- if (!$key && ($fileName && $fileTitle)) {
+ if (!$key && ($fileName)) {
$key = $this->_handleMediaFile(
$fileInfo['basename'],
- $fileTitle,
+ $fileName,
'',
$post->ID,
$this->_options['toolbox_files_url'] . '/'