Plugin Directory

Changeset 953292


Ignore:
Timestamp:
07/23/2014 07:54:12 AM (12 years ago)
Author:
kaisercrazy
Message:

Version 0.4

Location:
auto-files/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • auto-files/trunk/autofiles.php

    r953243 r953292  
    44Plugin URI: http://wpadami.com/cms-sistemleri/wordpress/auto-files-mini-bir-auto-attachments.html
    55Description: This plugin is minified version of Auto Attachments. Supported attachment types are Word, Excel, Pdf, PowerPoint, zip, rar, tar, tar.gz
    6 Version: 0.3
     6Version: 0.4
    77Author: Serkan Algur
    88Author URI: http://www.wpadami.com
     
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1111*/
     12
    1213// Stop direct call
    1314if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    1415                die('You are not allowed to call this page directly.');
    1516}
     17// CSS Style Loading
    1618
    17 // CSS Style Loading
    1819if (!is_admin()){
    1920    wp_enqueue_style('autofilesstyle', plugins_url('/auto-files/autofiles.css'), __FILE__ );
    2021}
     22
    2123function multilingual_af( ) {
    2224                load_plugin_textdomain('autof', false, dirname(plugin_basename(__FILE__)) . '/languages');
     
    5456                        "applicationvnd.ms-excel.sheet.macroEnabled.12",
    5557        )));
     58
    5659    if ($files) {
    5760        $filehtml .= '<div class="files section group">';
     
    7578
    7679add_filter('the_content', 'autof_insertintoContent');
     80
    7781function autof_insertintoContent($content) {
    7882    global $post;
    7983    $metapost = get_post_meta($post->ID,'aa_post_meta',TRUE);
    80     $metapage = get_post_meta($post->ID,'aa_page_meta',TRUE);
    8184        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"){
    8386                    $content .= autof_show_files();
    8487                    return $content;
     
    8992
    9093        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"){
    9295                    $content .= autof_show_files();
    9396                    return $content;
  • auto-files/trunk/metaboxes.php

    r944333 r953292  
    11<?php
     2
    23// Stop direct call
     4
    35if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
     6
    47                die('You are not allowed to call this page directly.');
     8
    59}
    6 
    7 
    810//Metabox For Pages
    9 add_action('admin_init','aa_meta_init');
     11add_action( 'add_meta_boxes','aa_meta_init');
     12add_action('save_post','aa_meta_save');
    1013
    1114function aa_meta_init()
     
    1316        add_meta_box('all_page_meta',  __('Show Auto Files?','autof'), 'aa_meta_page', 'page', 'side', 'high');
    1417        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');
    1718}
    1819
    19 function aa_meta_page()
     20
     21function aa_meta_page($post)
    2022{
    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);
    2624    ?>
    2725    <p><?php _e('Show Files Section','autof');?>
    28     <select id="aa_post_meta" name="aa_page_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>
    3129    </select></p>
    3230    <?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() ). '" />';
    3433}
    3534
    36 function aa_meta_post()
     35function aa_meta_post($post)
    3736{
    38     global $post;
    3937    $meta = get_post_meta($post->ID,'aa_post_meta',TRUE);
    40     if (isset($meta['show'])){$gshow = $meta['show'];}
    4138    ?>
    4239    <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>
    4643    </select></p>
    4744    <?php
    4845    // 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() ). '" />';
    5048}
    5149
    52 function aa_meta_save($post_id)
     50function aa_meta_save()
    5351{
     52    global $post;
    5453    // authentication checks
    5554    // 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;
    5756    // check user permissions
    5857    if ($_POST['post_type'] == 'page')
    5958    {
    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;
    7460    }
    75     elseif($_POST['post_type'] == 'post')
     61    else
    7662    {
    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    }
    7865
    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);
    9267
     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);
    9376    }
     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;
    9483}
     84
     85
    9586function my_meta_clean(&$arr)
    9687{
     
    10293            {
    10394                my_meta_clean($arr[$i]);
    104 
    10595                if (!count($arr[$i]))
    10696                {
     
    122112    }
    123113}
    124 
    125114?>
  • auto-files/trunk/readme.txt

    r953243 r953292  
    3434
    3535= Version 0.3 =
     36* Tested. Full Working.
     37
     38= Version 0.3 =
    3639* Fixes for file attachments show. Auto Attachments settings fully supported with this version.
    3740
Note: See TracChangeset for help on using the changeset viewer.