How to customize a permalink (URL) structure?

The GUID field is not a URL and should never be used for that purpose. It’s a unique identifier that happens to look like a URL, but it should never be trusted as such. WordPress has a number of functions for retreiving attachment URLs and files: get_children get_attached_media the_attachment_link get_attachment_link wp_get_attachment_link wp_get_attachment_image wp_get_attachment_image_src wp_get_attachment_url wp_get_attachment_thumb_file … Read more

Insert terms for custom taxonomy on plugin activation, or each page load (init hook)

50 is relatively not much, and you should create them on the plugin activation hook. For more then 100 (just pulled the number out of my ass 😉 do your own testing on some slow shared hosting) I would create a settings page and initialize the DB from there. The reason is that users do … Read more

JS Support Ticket – Auto create WP account

wp_create_user is your friend! It takes a username, password, and email: wp_create_user( $username, $password, $email ); And here’s an example: $user_id = username_exists( $user_name ); if ( !$user_id and email_exists($user_email) == false ) { $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false ); $user_id = wp_create_user( $user_name, $random_password, $user_email ); } else { $random_password = __(‘User already exists. … Read more

Where to add hooks in a class

Where to add hooks in a class? “In class-based object-oriented programming, a constructor (abbreviation: ctor) is a special type of subroutine called to create an object. It prepares the new object for use, often accepting arguments that the constructor uses to set required member variables.” Source: Wikipedia. The constructor is not the place to add … Read more

How to periodically scrape and cache strings from remote txt files. – My First Plugin

The Transient API may help you here. A transient is variable stored for a defined amount of time. function filemtime_remote( $url ) { $list = file_get_contents( $url , null , null , 0 , 200); $important = explode(“Last modified: “,$list)[1]; $mydate = substr($important, 0, 21); return $mydate; } The above is your current code which … Read more