I already fixed the problem by manually inserting rows into the database.
First I ran this query to grab the posts that did not have a ‘page_template’ row :
SELECT p.ID FROM wp_posts p WHERE p.post_type
= “wpdmpro” AND p.ID NOT IN (SELECT post_id FROM wp_postmeta WHERE meta_key
= “__wpdm_page_template”);
Then I used a script to write my insert queries:
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES(3749, ‘__wpdm_page_template’, ’56ec6406ad3cf’);
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES(3750, ‘__wpdm_page_template’, ’56ec6406ad3cf’);
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES(3752, ‘__wpdm_page_template’, ’56ec6406ad3cf’);
INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES(3755, ‘__wpdm_page_template’, ’56ec6406ad3cf’);
… (there were 39 of them)
So I’ve fixed the problem on my site, I just wanted to let you know about the problem with the add-on.
The feature is available, and works for the most part, but does not update all the packages. Packages that were imported before Default Value Add-On is installed (and didn’t have a template assigned) do not get updated. They don’t get updated because there isn’t a row in wp_postmeta with __wp_page_template for that package. There is no way to update those packages with the default page template.
Also, $order should probably be strtoupper($order) as WP_QUERY only accepts upper case for that option.
The default value for order_by should be ‘date’ NOT ‘ID’ . This is the current default for WP_QUERY and should persist.
Test Cases:
// No values
[wpdm_tree category=”agency-policy” download_link=”1″]
// Valid values
[wpdm_tree category=”agency-policy” download_link=”1″ order_by=”title” order=”ASC” ]
// Invalid Values
[wpdm_tree category=”agency-policy” download_link=”1″ order_by=”SOMETHING_IMPOSSIBLE” order=”NOT_ASC_OR_DESC” ]
Doesn’t accept php files, here’s a .tar
Included is the updated file, with a git-diff of the original plugin file and the updated file.
This update allows the wpdm_tree shortcode to accept order_by and order parameters, in accordance with the capabilities of WP_QUERY()
[wpdm-extended-shortcodes.php]
It first accepts the parameters and assigns the current default values (order_by = ID, order = DESC) if not defined. (~ line 21)
Sends these parameters in the AJAX request. (~line 30)
Accepts the AJAX parameters (~line 410) and applies them to the WP_QUERY() params (~line 420)
Example:
[wpdm_tree category="policy-documents" download_link="1" order_by="title" order="ASC" ]
Thanks again and I hope this helps!
It appears that when batch importing, the file is copied into download-manager-files
, correct? If two files of the same base name, but batch imported from different directories, the original file in download-manager-files
is overwritten. Every copied field needs to be timestamped, then, yes?
// wpdm-core.php ~line 457
function wpdm_dimport()
{
global $wpdb;
//array_shift($flds);
$fileinf = array();
// $files holds array with filename in UPLOAD_DIR where newly created package will be copied to
// $files = array($_POST[‘fname’]);
$new_file_name = time() . ‘wpdm_’ . $_POST[‘fname’];
$files = array($new_file_name);
$fileinf[‘access’] = $_POST[‘access’];
if (isset($_POST[‘password’]) && $_POST[‘password’] != ”) {
$fileinf[‘password_lock’] = 1;
$fileinf[‘password’] = $_POST[‘password’];
}
$fileinf[‘files’] = $files;
$post_id = wp_insert_post(array(
‘post_title’ ► esc_attr($_POST[‘title’]),
‘post_content’ ► esc_attr($_POST[‘description’]),
‘post_type’ ► ‘wpdmpro’,
‘post_status’ ► ‘publish’
));
wp_set_post_terms($post_id, $_POST[‘category’], ‘wpdmcategory’);
foreach ($fileinf as $meta_key ► $value) {
update_post_meta($post_id, “__wpdm_” . $meta_key, $value);
}
print_r($fileinf);
// Newly imported file is copied to $new_file_name in UPLOAD_DIR
// copy(get_option(‘wpdm_importdir’) . $_POST[‘fname’], UPLOAD_DIR . ‘/’ . $_POST[‘fname’]); // also inserts an extra ‘/’
copy(get_option(‘wpdm_importdir’) . $_POST[‘fname’], UPLOAD_DIR . $new_file_name);
do_action(‘after_add_package’, $post_id, $fileinf);
//@unlink(dirname(__FILE__).’/imports/’.$_POST[‘fname’]);
die(‘Done!’);
}
In the above example, the filename, test.rtf
is stored in __wpdm_files
, but what about the directory path? Normally, the file is in download-manager-files
, but with batch importing, it remains in the file structure, with a directory path deeper than download-manager-files
, correct? This is what I’ve observed in my debugging. So the question is: Where is this directory path stored?
I am also trying to access a file’s absolute path upon import. The above information works if the file is being added via “Add New Package” – it is placed in download-manager-files
and the filename stored in __wpdm_files as stated above.
If the file is imported via Bulk Import -> Select Import Dir (select a directory a couple levels down from download-manager-files) -> Import Selected Files, the file is not moved / copied to download-manager-files/
but instead left in it’s original directory path, correct? This is what I’ve observed through testing.
However, I cannot find where this path information is stored. The only wp_postmeta values are:
`
meta_id post_id meta_key meta_value
3699 1341 __wpdm_access a:1:{i:0;s:5:”guest”;}
3700 1341 __wpdm_files a:1:{i:0;s:8:”test.rtf”;}
`
So in the scenario where a file is imported through Bulk Import [select nested directory] -> Import Selected Files, how do you get the absolute path?