Forum Replies Created

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter twcfan92

    (@twcfan92)

    That worked, but it also disabled helpful notices like when I have noindex turned on. Not a huge deal I guess, since WordPress shows that notice as well. Thanks!

    Thread Starter twcfan92

    (@twcfan92)

    And that’s the problem. Until you started doing this, I was relying on the notifications area for problems like forgetting to turn off the noindex option. Now I either have to check every site every time I’m in the admin area or ignore it altogether. Obviously this isn’t a big deal when you only manage one or two sites, but it’s a real time waster when you manage say 30.

    I don’t understand the purpose of keeping these update notices around indefinitely unless you hide them. How showing information about an update a person performed say six months ago useful?

    • This reply was modified 3 years, 12 months ago by twcfan92.
    twcfan92

    (@twcfan92)

    I’m having the same issue on a number of (but not all) sites using Yoast. No caching plugins here.

    Thread Starter twcfan92

    (@twcfan92)

    As I stated above, I tried both of those things to no avail. Fortunately, the issue magically resolved itself after a few hours.

    Thread Starter twcfan92

    (@twcfan92)

    The parent theme is MH TechMagazine.

    Thread Starter twcfan92

    (@twcfan92)

    It’s back! Here’s a screenshot:

    https://twcclassics.com/temp/child.jpg

    As you can see, I’m editing a child theme. However, the first five files and folders on the right are from the parent theme. And if I try to edit one of the files, I get the following error:

    Sorry, that file cannot be edited.

    Which is good because you shouldn’t be allowed to edit parent theme files from within a child theme, but the question remains – why are they showing up?

    Thread Starter twcfan92

    (@twcfan92)

    Well this is weird. I upgraded again, and now it’s showing the correct files. Must have been that caching bug.

    twcfan92

    (@twcfan92)

    This worked for me. Add it to your theme’s functions.php file.

    
    add_action('admin_head', 'removeMessage');
    
    function removeMessage()
    {
        echo <<<EOF
    <style>
    #message
    {
        display: none;
    }
    </style>
    EOF;
    }
    
    twcfan92

    (@twcfan92)

    It would be nice if we could dismiss it. In the meantime, here’s a workaround. Add it to your theme’s functions.php file.

    
    add_action('admin_head', 'removeMessage');
    
    function removeMessage()
    {
        echo <<<EOF
    <style>
    #message
    {
        display: none;
    }
    </style>
    EOF;
    }
    
    • This reply was modified 7 years ago by twcfan92.

    The instructions are actually pretty clear. Install the plugin, activate the plugin, and then change the navigation code in your theme. How you accomplish the last part varies wildly, since every theme is structured differently.

    Some theme authors make it easy, others make it difficult (if not impossible). Since there are thousands of themes out there, it would be impossible for the plugin authors to explain how to update them all.

    So you should be giving your theme one star for making a simple task so difficult, not this plugin. And yes, you should always create a child theme if you decide to change the parent theme’s code.

    Thread Starter twcfan92

    (@twcfan92)

    Thanks for the reply. I actually figured this out the other day. For the benefit of anyone else trying to do the same thing, here’s the code I used. In my add_attachment hook, I added the following:

    add_action('as3cf_setting_object-prefix', 'setS3Path_' . $fcategory2, 10, 1);

    $fcategory2 is my attachment category, which is what I’m using to determine which folder to put the file in. The function setS3Path_X looks something like this…

    function setS3Path_audio($value)
    {
        return 'wp/audio';
    }
    
    function setS3Path_video($value)
    {
        return 'wp/video';
    }

    …with audio and video being different attachment categories.

    Thread Starter twcfan92

    (@twcfan92)

    Thanks for your reply. I tried the following, but it didn’t work. It still uploads to the root. In fact, it seems to ignore the code altogether. I tried replacing ‘wp/’ with gibberish, but the path didn’t change after I uploaded a file.

    add_filter('as3cf_object_meta', 'as3cf_update_meta', 10, 2);
    
    function as3cf_update_meta($args, $post_id)
    {
        $guid = get_the_guid($post_id);
        $guid = str_replace('https://' .  $_SERVER['HTTP_HOST'] . '/wp/wp-content/uploads/', '', $guid);
    
        $args['Key'] = 'wp/' . $guid;
    
        return $args;
    }

    Thread Starter twcfan92

    (@twcfan92)

    Thanks David. I actually figured this out the other day. Basically what I did was create a hook that runs whenever a post is updated that’s an attachment. The code checks to see if the attachment being updated is in the root of the uploads folder (since that’s where the files are uploaded). If it finds it there it moves it to a category folder (based on whatever attachment category is assigned to it). If no category has been assigned or the file is already in the category folder, it doesn’t do anything. I appreciate your help!

    Thread Starter twcfan92

    (@twcfan92)

    Thank you for the information. I was able to output the category of an attachment. So now the only question that remains is how do I put the file I uploaded into a directory named after the category I assigned the file? I tried the code below, but it didn’t work.

    add_filter('wp_handle_upload_prefilter', 'cud_pre_upload');
    add_filter('wp_handle_upload', 'cud_post_upload');
    
    function cud_pre_upload($file)
    {
        if (!empty($file['name']))
        {
            $wp_filetype = wp_check_filetype($file['name']);
            $cud_file_ext = (!empty($wp_filetype['ext'])) ? $wp_filetype['ext'] : '';
            $cud_file_type = (!empty($wp_filetype['type'])) ? $wp_filetype['type'] : '';
        }
    
        add_filter('upload_dir', 'cud_custom_upload_dir');
    
        return $file;
    }
    
    function cud_post_upload($fileinfo)
    {
        remove_filter('upload_dir', 'cud_custom_upload_dir');
    
        return $fileinfo;
    }
    
    function cud_custom_upload_dir($param)
    {
        $cat = get_the_category();
    
        if (!is_array($cat))
            return;
    
        $npath = '/files/' . $cat->name;
        $param['path'] = $param['path']  . $npath;
        $param['url']  = $param['url'] . $npath;
        $param['basedir'] = $param['basedir'] . $npath;
        $param['baseurl'] = $param['baseurl'] . $npath;
    
        return $param;
    }

    Any ideas? Is this even possible?

    Thread Starter twcfan92

    (@twcfan92)

    Thanks for your reply and information! I have since discovered the feature in your plugin that allows you to set the category and tags when the files are uploaded (which is awesome). So I might not need to mess with the hooks if I can get the Custom Upload Directory plugin to work with this.

    So my only question now is if I upload a file and assign a category to it, where is that information stored? I searched my entire WordPress database, but couldn’t find it. I found the category in the taxonomy table, but nothing that shows that file #19 is associated with taxonomy #2, if that makes sense.

Viewing 15 replies - 1 through 15 (of 16 total)