'attachment',
'orderby' => 'menu_order',
'posts_per_page' => 100,
'post_parent' => $post->ID
));
if ($attachments)
{
$content .= '
';
foreach ($attachments as $attachment)
{
$class = "post-attachment mime-" . sanitize_title($attachment->post_mime_type);
$content .= '- ' . $attachment->post_title . ' (' . wpatt_format_bytes(filesize(get_attached_file($attachment->ID)));
$wpatt_option_showdate_get = get_option('wpatt_option_showdate');
if ($wpatt_option_showdate_get == '1')
{
$wpatt_date = new DateTime($attachment->post_date);
$content .= '
' . $wpatt_date->format('d.m.Y') . '
';
}
$content .= ') ';
}
$content .= '
';
}
return $content;
}
/* Register Settings */
add_action('admin_init', 'wpatt_reg_settings');
function wpatt_reg_settings()
{
register_setting('wpatt_options_group', 'wpatt_option_showdate', 'intval');
register_setting('wpatt_options_group', 'wpatt_option_localization');
/* Preopulate 'Attachments' */
$wpatt_option_showdate_get = get_option('wpatt_option_showdate');
if (get_option('wpatt_option_localization') == '')
{
update_option('wpatt_option_localization', 'Attachments');
}
}
/* Here starts the code for the option panel */
add_action('admin_menu', 'wpatt_plugin_menu');
function wpatt_plugin_menu()
{
add_options_page('WP Attachments - Settings', 'WP Attachments', 'manage_options', 'wpatt-option-page', 'wpatt_plugin_options');
}
function wpatt_plugin_options()
{
if (!current_user_can('manage_options'))
{
wp_die(__('You do not have sufficient permissions to access this page.'));
}
if (isset($_POST['Submit']))
{
$wpatt_option_localization_get = $_POST["wpatt_option_localization_n"];
update_option('wpatt_option_localization', $wpatt_option_localization_get);
if (isset($_POST['wpatt_option_showdate_n']))
{
update_option('wpatt_option_showdate', '1');
}
else
{
update_option('wpatt_option_showdate', '0');
}
}
echo '