Category: WordPress

  • Date

    HV:

    // Display mp3 five days after airdate
    if ( strtotime( '-5 days' ) > strtotime( $airdate ) )
        $audio_url = 'http://hearvox.com/episode/cast/' . $airyr . '/' . $fileID . '.mp3';
    
    <?php
    $d = new DateTime( '2010-01-08' );
    $d->modify( 'first day of next month' );
    echo $d->format( 'F' ), "\n";
    ?>
    

    http://www.php.net/manual/en/datetime.modify.php

    http://www.php.net/manual/en/datetime.diff.php

  • hNews

    testing hNews plugin fields

    [[code]hnews_meta[/code]]

    [/js]

  • Storify

    listing them in some what the order i encountered them (not order of importance), and much from the pov of a new user:

    STUCK IN CREATION: i’m a new user. i hit “Create”, then “Save Now”, “Sign up with FB” (or “Sign Up” then “Sign up with FB”).

    once logged in, tho, it still says “Sign Up” and “Login” on up-right, w/ no “Back to Profile” or User links. so i’m stuck, no way to get to my settings, profile, logout. see screenshot, the story was saved, so i’m logged in, but the top button still wants me to “Login ”

    DRAFTS: once you’ve signed up and come back to the site, the first thing a user might want to do is work on Draft(s). but via site pages have no obvious link to the users stories. the top-right User select-menu lists has “Settings”, “Subscriptions”, etc. but not “Profile”. that’s b/c the menu itself (the username/gravatar) is the link to “Profile”.

    generally, tho, while a select menu can have links, it isn’t itself a link. so it’s a discoverability issue. and your Edit screen User select-menu is just the opposite: the username is NOT hot and the options DO list a Profile link.

    PROFILE: in fact the user “profile” page is not named “profile” anywhere. there is no link on the text “Profile” anywhere (except Edit). the Settings page has “Settings” heading text and a “/settings” URL, but a user’s profile has no indication “profile” is the term for that page.

    a side terminology note, in the Feedback section, you often refer to Settings->Profile. this implies a relationship that doesn’t exist, ie, the “Settings” page does not have a subset/child Settings->”Profile” page. (more…)

  • UNIX

    change prompt:
    PS1='[${USER}@${HOSTNAME} ${PWD}]$ '

  • Here’s Lookin’

    Here’s Lookin’ @ You, Niño #casablanca 1942-11_26 🙂
    heres-lookin-you-nino-casablanca-1942-11_26

    By default that slug is version of the post’s title, processed by WordPress to use only lower-case alphanumeric characters, also underscore and the dash (if not at the beginning or end of the title). WordPress takes the title and:
    * Converts upper-case letters to lower-case.
    * Converts accented letters to their unaccented equivalent.
    * Removes all punctuation and symbols, except underscore and dash.
    * Removes leading and trailing dash.
    * Replaces space(s) with a dash.

    So a slug allows lower-case alphanumeric characters, underscore, and dash ([a-z], [0-9], [_], [-]).
    * Allow underscore (_),
    * Allow dash (-), unless leading or trailing.

    title, slug, and (working) permalink:
    12345678901234567890123456789012345678901234567890123456789012345678901234567890
    12345678901234567890123456789012345678901234567890123456789012345678901234567890
    https://dev.pubmedia.us/2012/01/
    12345678901234567890123456789012345678901234567890123456789012345678901234567890/

    Page slugs shouldn’t be numeric-only.

    http://core.trac.wordpress.org/ticket/14238

    Here’s Lookin’@You,_Niño #casablanca 1942/11/26 🙂
    heres-lookinyou_nino-casablanca-19421126

    Here’s Lookin’@-You,_Niño #casablanca 1942/11/26 🙂
    heres-lookinyou_nino-casablanca-19421126

    Here’s Lookin’ @ You,_Niño #casablanca 1942/11/26 🙂
    heres-lookin-you_nino-casablanca-19421126

    Here’s Lookin’ @ You, Niño #casablanca 1942/11_26 🙂
    heres-lookin-you-nino-casablanca-194211_26

  • Revision Management

    http://codex.wordpress.org/User:MichaelH/Testing/Revisions

    http://codex.wordpress.org/Revision_Management

    http://pubmedia.us/word/2010/03/wp-revs/

    http://codex.wordpress.org/Post_Types#Revisions
    Revisions
    A “revision” is used to hold draft posts as well as any past revisions of existing posts or pages. These are basically identical to the main post/page that they are for, but have that post/page as their parent.

    http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions

    register_post-type()
    post type is a native or “built-in” post_type
    this is a built-in native post type (post, page, attachment, revision, nav_menu_item)

    wp-includes/post.php

    add_post_type_support()

    Disable post revisions in WordPress 3.0

    OPTIMIZE TABLE wp_posts;

    http://codex.wordpress.org/Function_Reference/wp_text_diff

    wp_get_post_revisions()

    wp_delete_post_revision()

    $return[‘post_name’] = $autosave ? “$post[ID]-autosave” : “$post[ID]-revision”;

    define( ‘AUTOSAVE_INTERVAL’, 120 );

    http://wordpress.org/extend/plugins/skip-identical-revisions/

  • Media Upload

    audio-player.php

    add_filter("attachment_fields_to_edit", array(&$this, "insertAudioPlayerButton"), 10, 2);
    			add_filter("media_send_to_editor", array(&$this, "sendToEditor"));
    
    		/**
    		 * Inserts Audio Player button into media library popup
    		 * @return the amended form_fields structure
    		 * @param $form_fields Object
    		 * @param $post Object
    		 */
    		function insertAudioPlayerButton($form_fields, $post) {
    			global $wp_version;
    			
    			$file = wp_get_attachment_url($post->ID);
    			
    			// Only add the extra button if the attachment is an mp3 file
    			if ($post->post_mime_type == 'audio/mpeg') {
    				$form_fields["url"]["html"] .= "<button type='button' class='button urlaudioplayer audio-player-" . $post->ID . "' value='[audio:" . attribute_escape($file) . "]' title='[audio:" . attribute_escape($file) . "]'>Audio Player</button>";
    				
    				if (version_compare($wp_version, "2.7", "<")) {
    					$form_fields["url"]["html"] .= "<script type='text/javascript'>
    					jQuery('button.audio-player-" . $post->ID . "').bind('click', function(){jQuery(this).siblings('input').val(this.value);});
    					</script>\n";
    				}
    			}
    			
    			return $form_fields;
    		}
    
    		/**
    		 * Format the html inserted when the Audio Player button is used
    		 * @param $html String
    		 * @return String 
    		 */
    		function sendToEditor($html) {
    			if (preg_match("/<a ([^=]+=['\"][^\"']+['\"] )*href=['\"](\[audio:([^\"']+\.mp3)])['\"]( [^=]+=['\"][^\"']+['\"])*>([^<]*)<\/a>/i", $html, $matches)) {
    				$html = $matches[2];
    				if (strlen($matches[5]) > 0) {
    					$html = preg_replace("/]$/i", "|titles=" . $matches[5] . "]", $html);
    				}
    			}
    			return $html;
    		}