Changeset 953292
- Timestamp:
- 07/23/2014 07:54:12 AM (12 years ago)
- Location:
- auto-files/trunk
- Files:
-
- 3 edited
-
autofiles.php (modified) (5 diffs)
-
metaboxes.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
auto-files/trunk/autofiles.php
r953243 r953292 4 4 Plugin URI: http://wpadami.com/cms-sistemleri/wordpress/auto-files-mini-bir-auto-attachments.html 5 5 Description: This plugin is minified version of Auto Attachments. Supported attachment types are Word, Excel, Pdf, PowerPoint, zip, rar, tar, tar.gz 6 Version: 0. 36 Version: 0.4 7 7 Author: Serkan Algur 8 8 Author URI: http://www.wpadami.com … … 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 11 */ 12 12 13 // Stop direct call 13 14 if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { 14 15 die('You are not allowed to call this page directly.'); 15 16 } 17 // CSS Style Loading 16 18 17 // CSS Style Loading18 19 if (!is_admin()){ 19 20 wp_enqueue_style('autofilesstyle', plugins_url('/auto-files/autofiles.css'), __FILE__ ); 20 21 } 22 21 23 function multilingual_af( ) { 22 24 load_plugin_textdomain('autof', false, dirname(plugin_basename(__FILE__)) . '/languages'); … … 54 56 "applicationvnd.ms-excel.sheet.macroEnabled.12", 55 57 ))); 58 56 59 if ($files) { 57 60 $filehtml .= '<div class="files section group">'; … … 75 78 76 79 add_filter('the_content', 'autof_insertintoContent'); 80 77 81 function autof_insertintoContent($content) { 78 82 global $post; 79 83 $metapost = get_post_meta($post->ID,'aa_post_meta',TRUE); 80 $metapage = get_post_meta($post->ID,'aa_page_meta',TRUE);81 84 if (get_post_type() == 'post') { 82 if (!post_password_required() && ($metapost['show'] == 'yes' || $metapost['show'] == null || $metapost['fshow'] == yes)){85 if (!post_password_required() && $metapost != "no"){ 83 86 $content .= autof_show_files(); 84 87 return $content; … … 89 92 90 93 if (get_post_type() == 'page'){ 91 if (!post_password_required() && ($metapage['show'] == 'yes' || $metapage['show'] == null || $metapage['fshow'] == 'yes')){94 if (!post_password_required() && $metapost != "no"){ 92 95 $content .= autof_show_files(); 93 96 return $content; -
auto-files/trunk/metaboxes.php
r944333 r953292 1 1 <?php 2 2 3 // Stop direct call 4 3 5 if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { 6 4 7 die('You are not allowed to call this page directly.'); 8 5 9 } 6 7 8 10 //Metabox For Pages 9 add_action('admin_init','aa_meta_init'); 11 add_action( 'add_meta_boxes','aa_meta_init'); 12 add_action('save_post','aa_meta_save'); 10 13 11 14 function aa_meta_init() … … 13 16 add_meta_box('all_page_meta', __('Show Auto Files?','autof'), 'aa_meta_page', 'page', 'side', 'high'); 14 17 add_meta_box('all_post_meta', __('Show Auto Files?','autof'), 'aa_meta_post', 'post', 'side', 'high'); 15 16 add_action('save_post','aa_meta_save');17 18 } 18 19 19 function aa_meta_page() 20 21 function aa_meta_page($post) 20 22 { 21 global $post; 22 23 $meta = get_post_meta($post->ID,'aa_page_meta',TRUE); 24 if (isset($meta['show'])){$show = $meta['show'];} 25 23 $meta = get_post_meta($post->ID,'aa_post_meta',TRUE); 26 24 ?> 27 25 <p><?php _e('Show Files Section','autof');?> 28 <select id="aa_post_meta" name="aa_p age_meta[show]">29 <option value="yes" <?php if ($gshow == "yes") { _e('selected'); }?>><?php _e('Yes','autof');?></option>30 <option value="no" <?php if ($gshow == "no") { _e('selected'); }?>><?php _e('No','autof');?></option>26 <select id="aa_post_meta" name="aa_post_meta"> 27 <option value="yes" <?php selected( $meta, 'yes' ); ?>><?php _e('Yes','autof');?></option> 28 <option value="no" <?php selected( $meta, 'no' ); ?>><?php _e('No','autof');?></option> 31 29 </select></p> 32 30 <?php 33 echo '<input type="hidden" name="my_meta_noncename" value="' . wp_create_nonce(__FILE__) . '" />'; 31 echo '<input type="hidden" name="aa_meta_nonce" value="' . wp_create_nonce(__FILE__) . '" />'; 32 echo '<input type="hidden" name="post_type" value="' .get_post_type( get_the_ID() ). '" />'; 34 33 } 35 34 36 function aa_meta_post( )35 function aa_meta_post($post) 37 36 { 38 global $post;39 37 $meta = get_post_meta($post->ID,'aa_post_meta',TRUE); 40 if (isset($meta['show'])){$gshow = $meta['show'];}41 38 ?> 42 39 <p><?php _e('Show Files Section','autof');?> 43 <select id="aa_post_meta" name="aa_post_meta [show]">44 <option value="yes" <?php if ($gshow == "yes") { _e('selected'); }?>><?php _e('Yes','autof');?></option>45 <option value="no" <?php if ($gshow == "no") { _e('selected'); }?>><?php _e('No','autof');?></option>40 <select id="aa_post_meta" name="aa_post_meta"> 41 <option value="yes" <?php selected( $meta, 'yes' ); ?>><?php _e('Yes','autof');?></option> 42 <option value="no" <?php selected( $meta, 'no' ); ?>><?php _e('No','autof');?></option> 46 43 </select></p> 47 44 <?php 48 45 // create a custom nonce for submit verification later 49 echo '<input type="hidden" name="my_meta_noncename" value="' . wp_create_nonce(__FILE__) . '" />'; 46 echo '<input type="hidden" name="aa_meta_nonce" value="' . wp_create_nonce(__FILE__) . '" />'; 47 echo '<input type="hidden" name="post_type" value="' .get_post_type( get_the_ID() ). '" />'; 50 48 } 51 49 52 function aa_meta_save( $post_id)50 function aa_meta_save() 53 51 { 52 global $post; 54 53 // authentication checks 55 54 // make sure data came from our meta box 56 if (!wp_verify_nonce($_POST[' my_meta_noncename'],__FILE__)) return $post_id;55 if (!wp_verify_nonce($_POST['aa_meta_nonce'],__FILE__)) return $post->ID; 57 56 // check user permissions 58 57 if ($_POST['post_type'] == 'page') 59 58 { 60 if (!current_user_can('edit_page', $post_id)) return $post_id; 61 $current_data = get_post_meta($post_id, 'aa_page_meta', TRUE); 62 $new_data = $_POST['aa_page_meta']; 63 my_meta_clean($new_data); 64 if ($current_data) 65 { 66 if (is_null($new_data)) delete_post_meta($post_id,'aa_page_meta'); 67 else update_post_meta($post_id,'aa_page_meta',$new_data); 68 } 69 elseif (!is_null($new_data)) 70 { 71 add_post_meta($post_id,'aa_page_meta',$new_data,TRUE); 72 } 73 return $post_id; 59 if (!current_user_can('edit_page', $post->ID)) return $post->ID; 74 60 } 75 else if($_POST['post_type'] == 'post')61 else 76 62 { 77 if (!current_user_can('edit_post', $post_id)) return $post_id; 63 if (!current_user_can('edit_post', $post->ID)) return $post->ID; 64 } 78 65 79 $current_data = get_post_meta($post_id, 'aa_post_meta', TRUE); 80 $new_data = $_POST['aa_post_meta']; 81 my_meta_clean($new_data); 82 if ($current_data) 83 { 84 if (is_null($new_data)) delete_post_meta($post_id,'aa_post_meta'); 85 else update_post_meta($post_id,'aa_post_meta',$new_data); 86 } 87 elseif (!is_null($new_data)) 88 { 89 add_post_meta($post_id,'aa_post_meta',$new_data,TRUE); 90 } 91 return $post_id; 66 $current_data = get_post_meta($post->ID, 'aa_post_meta', TRUE); 92 67 68 $new_data = $_POST['aa_post_meta']; 69 70 my_meta_clean($new_data); 71 72 if ($current_data) 73 { 74 if (is_null($new_data)) delete_post_meta($post->ID,'aa_post_meta'); 75 else update_post_meta($post->ID,'aa_post_meta',$new_data); 93 76 } 77 elseif (!is_null($new_data)) 78 { 79 add_post_meta($post->ID,'aa_post_meta',$new_data,TRUE); 80 } 81 82 return $post->ID; 94 83 } 84 85 95 86 function my_meta_clean(&$arr) 96 87 { … … 102 93 { 103 94 my_meta_clean($arr[$i]); 104 105 95 if (!count($arr[$i])) 106 96 { … … 122 112 } 123 113 } 124 125 114 ?> -
auto-files/trunk/readme.txt
r953243 r953292 34 34 35 35 = Version 0.3 = 36 * Tested. Full Working. 37 38 = Version 0.3 = 36 39 * Fixes for file attachments show. Auto Attachments settings fully supported with this version. 37 40
Note: See TracChangeset
for help on using the changeset viewer.