| @@ -3,13 +3,22 @@ | ||
| 3 | 3 | Plugin Name: WP Attachments |
| 4 | 4 | Plugin URI: http://marcomilesi.ml |
| 5 | 5 | Description: Automatically shows your attachments under every post and page content. Simple. Automatic. Easy. As it has to be! |
| 6 | 6 | Author: Marco Milesi |
| 7 | -Version: 3.1.4 | |
| 7 | +Version: 3.2 | |
| 8 | 8 | Author URI: http://marcomilesi.ml |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +function wpa_action_init() | |
| 12 | +{ | |
| 13 | + load_plugin_textdomain( 'wp-attachments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); | |
| 14 | + update_option( 'wpa_version_number', '3.2' ); | |
| 15 | +} | |
| 11 | 16 | |
| 17 | +// Add actions | |
| 18 | +add_action('init', 'wpa_action_init'); | |
| 19 | +require_once(plugin_dir_path(__FILE__) . 'settings.php'); | |
| 20 | +require_once(plugin_dir_path(__FILE__) . 'ij-post-attachments.php'); | |
| 12 | 21 | |
| 13 | 22 | function wpatt_format_bytes($a_bytes) |
| 14 | 23 | { |
| 15 | 24 | |
| @@ -56,8 +65,9 @@ | ||
| 56 | 65 | |
| 57 | 66 | $attachments = get_posts(array( |
| 58 | 67 | 'post_type' => 'attachment', |
| 59 | 68 | 'orderby' => 'menu_order', |
| 69 | + 'order' => 'ASC', | |
| 60 | 70 | 'posts_per_page' => 100, |
| 61 | 71 | 'post_parent' => $post->ID |
| 62 | 72 | )); |
| 63 | 73 | |
| @@ -134,121 +144,17 @@ | ||
| 134 | 144 | $wpatt_option_showdate_get = get_option('wpatt_option_showdate'); |
| 135 | 145 | |
| 136 | 146 | if (get_option('wpatt_option_localization') == '') |
| 137 | 147 | { |
| 138 | - update_option('wpatt_option_localization', 'Attachments'); | |
| 148 | + $value = __('Attachments','wp-attachments'); | |
| 149 | + update_option('wpatt_option_localization', $value); | |
| 139 | 150 | } |
| 140 | 151 | } |
| 141 | 152 | |
| 142 | - | |
| 143 | - | |
| 144 | -/* Here starts the code for the option panel */ | |
| 145 | - | |
| 146 | - | |
| 147 | - | |
| 148 | 153 | add_action('admin_menu', 'wpatt_plugin_menu'); |
| 149 | 154 | |
| 155 | +function wpatt_plugin_menu(){ | |
| 156 | + add_options_page('WP Attachments - Settings', 'WP Attachments', 'manage_options', 'wpatt-option-page', 'wpatt_plugin_options'); | |
| 157 | +} | |
| 150 | 158 | |
| 151 | - | |
| 152 | -function wpatt_plugin_menu() | |
| 153 | - { | |
| 154 | - | |
| 155 | - add_options_page('WP Attachments - Settings', 'WP Attachments', 'manage_options', 'wpatt-option-page', 'wpatt_plugin_options'); | |
| 156 | - | |
| 157 | - } | |
| 158 | - | |
| 159 | - | |
| 160 | - | |
| 161 | -function wpatt_plugin_options() | |
| 162 | - { | |
| 163 | - | |
| 164 | - if (!current_user_can('manage_options')) | |
| 165 | - { | |
| 166 | - | |
| 167 | - wp_die(__('You do not have sufficient permissions to access this page.')); | |
| 168 | - | |
| 169 | - } | |
| 170 | - | |
| 171 | - | |
| 172 | - | |
| 173 | - if (isset($_POST['Submit'])) { | |
| 174 | - | |
| 175 | - $wpatt_option_localization_get = $_POST["wpatt_option_localization_n"]; | |
| 176 | - | |
| 177 | - update_option('wpatt_option_localization', $wpatt_option_localization_get); | |
| 178 | - | |
| 179 | - if (isset($_POST['wpatt_option_showdate_n'])) { | |
| 180 | - update_option('wpatt_option_showdate', '1'); | |
| 181 | - } else { | |
| 182 | - update_option('wpatt_option_showdate', '0'); | |
| 183 | - } | |
| 184 | - | |
| 185 | - if (isset($_POST['wpatt_option_includeimages_n'])) { | |
| 186 | - update_option('wpatt_option_includeimages', '1'); | |
| 187 | - } else { | |
| 188 | - update_option('wpatt_option_includeimages', '0'); | |
| 189 | - } | |
| 190 | - | |
| 191 | - } | |
| 192 | - | |
| 193 | - | |
| 194 | - | |
| 195 | - echo '<div class="wrap">'; | |
| 196 | - | |
| 197 | - screen_icon(); | |
| 198 | - | |
| 199 | - echo '<h2>WP Attachments</h2>'; | |
| 200 | - echo '<h3>OPTIONS</h3>'; | |
| 201 | - | |
| 202 | - echo '<div id="welcome-panel" class="welcome-panel">'; | |
| 203 | - | |
| 204 | - echo '<form method="post" name="options" target="_self">'; | |
| 205 | - | |
| 206 | - settings_fields('wpatt_option_group'); | |
| 207 | - | |
| 208 | - echo ' | |
| 209 | - | |
| 210 | - <table class="form-table"> | |
| 211 | - | |
| 212 | - | |
| 213 | - | |
| 214 | - <tr valign="top"> | |
| 215 | - | |
| 216 | - <th scope="row">Label for list header</th> | |
| 217 | - | |
| 218 | - <td><input type="text" name="wpatt_option_localization_n" value="'; | |
| 219 | - | |
| 220 | - echo get_option('wpatt_option_localization'); | |
| 221 | - | |
| 222 | - echo '" /> Insert here the label you want to use for the title of the attachments list. Default "<b>Attachments</b>"</td></tr>'; | |
| 223 | - | |
| 224 | - echo '<tr><th scope="row">Include Images?</th> | |
| 225 | - <td><input type="checkbox" name="wpatt_option_includeimages_n" '; | |
| 226 | - $wpatt_option_includeimages_get = get_option('wpatt_option_includeimages'); | |
| 227 | - if ($wpatt_option_includeimages_get == '1') { | |
| 228 | - echo 'checked=\'checked\''; | |
| 229 | - } | |
| 230 | - echo '/> Check this if you want to include images (.jpg, .jpeg, .gif, .png) from being listed.</td>'; | |
| 231 | - echo '</tr>'; | |
| 232 | - | |
| 233 | - echo '<tr><th scope="row">Show date?</th> | |
| 234 | - <td><input type="checkbox" name="wpatt_option_showdate_n" '; | |
| 235 | - $wpatt_option_showdate_get = get_option('wpatt_option_showdate'); | |
| 236 | - if ($wpatt_option_showdate_get == '1') { | |
| 237 | - echo 'checked=\'checked\''; | |
| 238 | - } | |
| 239 | - echo '/> Check this if you want to show when the file has been uploaded.</td>'; | |
| 240 | - echo '</tr></table>'; | |
| 241 | - | |
| 242 | - | |
| 243 | - | |
| 244 | - echo '</table><p class="submit"><input type="submit" class="button-primary" name="Submit" value="Update" /></p>'; | |
| 245 | - | |
| 246 | - echo '</form></div> | |
| 247 | - <h3>HELP, SUPPORT & FEEDBACK</h3> | |
| 248 | - <a href="http://wordpress.org/plugins/wp-attachments/" title "WP Attachments Wordpress Plugin>http://wordpress.org/plugins/wp-attachments/</a><br/> | |
| 249 | - This plugin is continuously developed by Marco Milesi focusing on simplicity, intuitiveness and cleanness. Keep updated :)<br/> | |
| 250 | - Thank You for using this plugin.</div>'; | |
| 251 | - | |
| 252 | - } | |
| 253 | 159 | |
| 254 | 160 | ?> |