Forum Replies Created

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

    (@cristofayre)

    Sorry for not replying sooner. Been adding more coding to my own non-Wordpress apps.

    Thought I’d add what I’ve done with my own apps such that you might gleam some ideas for your own plugin, (which incidentally I have mentioned in my instruction guide for any person using my apps who also have WordPress sites)

    One app is a “Page Lock”, akin to your own plugin, but for HTML pages. On the admin, there is a button they can press to generate 250 unique 6 letter passwords, which are stored in a flat database. The customer ‘requests’ a password from the vendor. A password is removed off the database, and transferred to another database, and sent to the customer. (When the script senses there are less than 100 codes left in the database, it emails the vendor asking them to top up the database with another 250 passcodes)

    When the customer goes to the locked page, it is hidden behind a lightbox. They enter the password, which is passed to the server via AJAX. It checks it with the second database, and if found, discards it. Meanwhile, javascript places a timed ‘cookie’ in localStorage. When that expires, it deletes itself, and locks the page again. If they now try to use the passcode a second time, it is not found in database, so refuses to open.

    Just a thought, but you might be able to add a counter such that when the available passwords drop below a certain level, they get sent an email telling them to add more. It should also be quite easy to add a password generator to the admin panel. (My own password generator uses any random letter from 20, 6 times giving 64 million possible combinations! Yes, there will probably be dupes, but they will be sent to different customers … and it would be quite tricky to try to ‘brute force’ the correct passcode.

    Just a thought …

    Thread Starter cristofayre

    (@cristofayre)

    Sorry for not explaining it too well. I have created a little infographic that might illustrate the point better. Had to use DropBox as there is no image upload on WordPress.org
    Featured image vs no featured image

    If the user adds a picture, the “default thumb” routine isn’t called, (or more correctly, does not run any code block ie “if ($post_id has_thumbnail){return}”) If the picture is missing, then it will use the default thumb associated with that category as specified by the extra exception plugin.

    (Or maybe I’m trying to do something it was never intended to do!)

    None of this is done via the admin panel. (I don’t think this will matter to your plugin, but just in case …) The submission form is displayed as a normal WP page. If the user adds a Feature Image, it is sent via AJAX to server and stored in the standard WP media folder, and assigned a code. Via the AJAX response, this code is then embedded in the form via a hidden input. When they finally submit the form, it is uploaded as a “draft” or “pending” post, and uses the hidden code to associate the image in the media folder as a Featured Image for that post.

    My theory is: When I set it to “published”, if no Featured Image is present, then the default thumbnail is substituted. =OR= when the page is displayed to an end user, if no FI is present on the post, the default thumb for that category is shown, (as per the “free” thumb in the infographic)

    Apologies if this is still all gobbledy-gook.

    • This reply was modified 2 years, 11 months ago by cristofayre.
    Thread Starter cristofayre

    (@cristofayre)

    THIS is very insightful! I didn’t think it was THAT simple to create a plugin, (albeit simplified) I did wonder about the plugin upgrade ‘problem’ erasing amendment; this now solves that. Many thanks. (and for explaining “10” and “2”)

    ** You might have already covered this with the “regular DFI set in media settings”, but presume that refers to the single image in the admin area.

    Sorry to be a pain, but need clarification on the use default or user uploaded Feature Image conditional, (ie if they add a feature image to a their post, don’t overwrite it with the default image) Perhaps it has something to do with the “has_thumbnail” function. I don’t write PHP, (more javascript / perl / css / html) Presume it would be something along the lines of – syntax incorrect:

    
    if ($post_id has_thumbnail){
    return //from set exceptions plugin
    }
    else{
    if (catergory === "free"){
    // use DFI for free cat etc
    }
    else if (category === "tec"){
    // use default icon for 'tec'
    }
    etc

    Basically, I have a front end submission form where they can submit to six categories. If they include a FI, use that. If not, substitute with the DFI for the category. (Your code explains how to do the latter, but not sure if I need to add more code up front to use the user submitted image)

    Again, lot of helpful info for someone just finding their way around PHP of WordPress

    Thread Starter cristofayre

    (@cristofayre)

    Having delved a little deeper, it seems the code sets up the button as a file input (!) so that it acts as a “Browse…” button and submit button all in one! Clever, but a devil to decode when you want to add front end validation to decipher what’s happening where!

    Thread Starter cristofayre

    (@cristofayre)

    First of, apologies. I got just about everything wrong !!

    When you hover over an image in media library list view, it shows “post_id=xxxx” I assumed that was the actual textual post it was assigned to show up on, and was looking for another ID number for the actual image. (I solved if by installing a plugin that shows ID numbers … and that showed the same number as the link in the status bar, ie “…/post.php?post=1893&action=edit&classic-editor”

    Apparentely, the “append” link shows if you upload images directly to the media library. Even if you then set the “featured image” of the post, it doesn’t associate that image with the page in the library. Seems it’s only “attached” if you use the upload feature image of the post setting. (Absolutely nothing to do with the plugin, but thought I’d clarify in case anyone else reads this post). You can manually ‘attach’ it to a post for ‘good housekeeping’

    The “only loading square images” was confusion caused by the ‘settings’ panel. Yes, it uploads the full image, but then crops the sides off when displaying it in the admin panel! (The other settings are set to default 150×150, 300×300 and 1024×1024, so that may be why the thumbhail is shown cropped. Helpfully(!), my theme uses NONE of these sizes. It uses 200 x 140, 60 x 42, 300 x 165, and 658 x 300 (I’m not gonna mess with the default sizings at this stage lest I foul things up) If I design image for the latter scroller, the other sizes get cropped so no longer make sense. I have now created the graphics such that the centre of the large image gets cropped to the aspect ratios above, and the slider image is ‘padded’ to the sides. (Again, just thought I’d add it here in case anyone faces a similar problem with images)

    So again, sorry to have ‘wasted’ your time, but I am grateful for the prompt response.

    Incidentally, I am using a plugin that allows people to post pending articles without entering the admin area. If they don’t add a featured image, your plugin should substitute a default graphic

    Thread Starter cristofayre

    (@cristofayre)

    (Reading my emails from top down, so just seen the reply to the first problem)

    Again, works perfectly. Many thanks for all your help.

    ** One “minor” issue – or maybe something for a future update – Can the speed of the slider be part of the customiser as the images are swapping a little fast at present

    Thread Starter cristofayre

    (@cristofayre)

    Perfect! Many thanks for this code snippet. Thanks for your assistance

    Thread Starter cristofayre

    (@cristofayre)

    Thanks for your response. Not sure of how to place a screenshot on here, so have provided a link: https://www.dropbox.com/s/sws2czp9uwkwkvd/blog_pic.jpg?dl=0

    The heading with the line is fine. What I would like to do – if poss – is to remove the repeated tag under the featured picture. (Title, date, author and comments to remain)

    Thread Starter cristofayre

    (@cristofayre)

    I was “half right” with the above!

    Program works fine when run on the intended Unix platform, (ie web server) but for anyone developing a site using an offline setup, expect the above errors. It seems that when used on the Windows enviroment, one program or another is incapable of generating the various thumbnails, and the “sizes” array that fits within the “wp_attachment” SQL entry.

    It still shows the image, but PHP throws up the warning message

    Thread Starter cristofayre

    (@cristofayre)

    Sorry everone!
    I got myself confused BIG TIME. Earlier, in an attempt to get things going, I renamed / moved “wp_postmeta” to “cristofa_postmeta” … and then changed “wp_config” to “_wp”, so of course “postmeta” was missing, hence no images!!

    Renamed it back to “wp_postmeta” and Bingo! images back. I’m a “Happy Bunny” again. (Now all I gotta do is manually add thumbnails to 1200 posts!! 600 offline and 600 online!!)

    Thread Starter cristofayre

    (@cristofayre)

    I WAS going to say I was wrong!!

    I just noticed I had 27 TABLES on the left side of PHP MYADMIN, half prefixed “cristofa_” and half with “wp_”

    I remembered I’d imported data from online site, so double checked the prefix. Sure enough, it was the default “wp_” setting. The “cristofa_” is what I’d used on the offline set when setting up.

    So I edited “wp_config”, set the prefix to “wp_” … and all the images have reappeared … or so I thought! But I was viewing the online site! (I have to click HOSTMAN to select if I want to go online to use live site, and click again to use offline server since both online and offline share same domain name! An I get confused as to whether red button means online or offline!!)

    Suffice to say, made “diddly-squat” difference; still got grey placeholders.

    Thread Starter cristofayre

    (@cristofayre)

    Ha-Ha-Ha
    I told you I downloaded all the files to WordPress. It now tells me “All the files you uploaded are now available in the media library …” Yep, you guessed it: NOTHING!

    Thread Starter cristofayre

    (@cristofayre)

    Just done a little more “digging”, and from what I can follow, the script interogates the “_wp_attachment_metadata” to get the width, height, file, sizes and meta_data. Wonder if it is the sizes array that’s missing, and throwing the whole thing. I’ve listed one of my entries, and as you see it jumps from file to image_meta: no sizes are serailised. But in the program, line 306, it has
    $tpm = wp_get_attachment_metadata( $thumbnail_id );
    $sizes = $tpm[‘sizes’];”
    ie seeking the sizes array, which is then used in the for loop that’s generating the error at line 313

    a:4:{s:5:”width”;i:298;s:6:”height”;i:298;s:4:”file”;s:22:”2015/07/washnnwax4.jpg”;s:10:”image_meta”;a:11:{s:8:”aperture”;i:0;s:6:”credit”;s:0:””;s:6:”camera”;s:0:””;s:7:”caption”;s:0:””;s:17:”created_timestamp”;i:0;s:9:”copyright”;s:0:””;s:12:”focal_length”;i:0;s:3:”iso”;i:0;s:13:”shutter_speed”;i:0;s:5:”title”;s:0:””;s:11:”orientation”;i:0;}}

    This might give you a few pointers if it’s something that the latest WordPress version has ‘broken’

    ** I should add that this is on a Windows offline installation if that’s throwing a spanner in the works

    Thread Starter cristofayre

    (@cristofayre)

    OH DEAR, OH DEAR, OH DEAR …

    I developed an online site (on the wrong domain) and then had to port it to new domain. Taken a few days to import files, settings etc. All the posts are OK, all plugins are OK – guess what’s coming – ALL IMAGES ARE MISSING DUE TO THE MEDIA LIBRARY BEING INVISIBLE TO PROGRAM

    Since it uploaded an image to “07” folder, I copied ALL 600 images to that folder … and none of them show either.

    So the moral is … if use the media library YOU’RE IN TROUBLE if you ever move to another domain / server; you will have to reupload every image AGAIN via the library, and then change EVERY link in EVERY POST to recognise the new folder. Which in all honesty IS A JOKE.

    Only way I can see of getting this working is to change EVERY link in the pre-uploaded data, and make them point to an external image folder on server.

    Thread Starter cristofayre

    (@cristofayre)

    It’s OK folks, solved it. Did it as proposed at the end. If anyone needs to do the same sort of thing, here’s the code for how I did it:

    `#!/usr/bin/perl
    use CGI qw/:standard/;
    print “content-type: text/html\n\n”;
    use CGI::Carp qw( fatalsToBrowser );

    open (WIKI, “<../../wikaniko/greenproducts.wordpress.2015-05-25.xml”); # The file containing all the posts
    @wiki=<WIKI>;
    close(WIKI);
    $count=0;

    for ($x=0; $x<@wiki; $x++){
    $line=$wiki[$x];
    if($line =~ m|<title>(.*?)</title>|igs){ # Locates title, link and category of post
    $title=$1;
    }
    if($line =~ m|<link>(.*?)</link>|igs){
    $link=$1;
    }
    if($line =~ m|<category domain=”category” nicename=”(.*?)”>(.*?)</category>|igs){
    $cat=$1;
    $outText[$count]=”$cat|$title|$link”.”\n”; # Creates a single line. Save to array
    $count++;
    }
    }

    @outText = sort { lc($a) cmp lc($b) } @outText; # Sort the array alphabetically so all category entries are together
    open (WIKI, “>../../wikaniko/PDF_link_data.txt”);
    print WIKI @outText;
    close(WIKI);

    print “All done”;

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