Half-Elf on Tech

Thoughts From a Professional Lesbian

Author: Ipstenu (Mika Epstein)

  • Sidebar Login Widget

    Sidebar Login Widget

    This comes up a lot.

    The basic concept is you want to allow users to log in and out via a sidebar, and never see the admin-end of WP. There’s an awesome plugin called Sidebar Login that already does this, but I decided to play around and make a dead simple widget. There’s no ajax going on here, and very little code since it all calls the built in functions and filters.

    It lets you make a few choices, as to what verbiage you want to use, and if you want to show login/registration info or not. The registration link won’t work if you have registration turned off, natch.

    All the code is here at Hack: Sidebar Login Widget

    Really those hacks are more ‘mu-plugins’ that I don’t want to support, but still wrote, but you get the idea.

    I’ve taken to writing up the code, when I can, for people in the forums a little more, since it helps me as a developer get better with WordPress. I’m still new at wrangling widgets, so this was a new, and interesting, experience for me. That brought up questions for me, as to where people like the plugin ‘settings’ to be.

    [polldaddy poll=6676462]

  • Sidebar Login Widget

    Sidebar Login Widget

    So this happened after people asked me about how to make a widget. This makes a slightly customizable widget that will let you have a slightly customized login form via a widget.

    As with all hacks, you’re on your own for support. Code is GPLv2, and it should be translatable.

    Download Code

    The code is in a .txt file. Rename if .php and toss it in mu-plugins

    Download TXT

    Code

    .

    Sidebar Login Widget is released WITHOUT any support, and you can
    use it at your own risk. The code should work, but I’m not spending
    a lot of time on it.
    */

    if (!defined(‘ABSPATH’)) {
    die();
    }

    // Register the widget
    function sli_register_widgets() {
    register_widget( ‘sli_SLI_widget’ );
    }
    add_action( ‘widgets_init’, ‘sli_register_widgets’ );

    // This is the widget!
    class sli_SLI_widget extends WP_Widget {

    function sli_SLI_widget() {
    $widget_ops = array( ‘classname’ => ‘sli_add_users’, ‘description’ => ‘Sidebar Login Form.’ );
    $control_ops = array( ‘width’ => 300, ‘height’ => 350, ‘id_base’ => ‘sli-add-user-widget’ );
    $this->WP_Widget( ‘sli-add-user-widget’, ‘Sidebar Login’, $widget_ops, $control_ops );
    }

    function widget( $args, $instance ) {
    extract( $args );

    /* User-selected settings. */
    $title = apply_filters(‘widget_title’, $instance[‘title’] );
    $errormsg = $instance[‘errormsg’];
    $lostmsg = $instance[‘lostmsg’];
    $show_for = $instance[‘show_for’];
    $show_reg = $instance[‘show_reg’];

    /* Before widget (defined by themes). */
    echo $before_widget;

    /* Title of widget (before and after defined by themes). */
    if ( $title )
    echo $before_title . $title . $after_title;

    // Code Goes Here

    global $user_login, $post;
    $redirect = $_SERVER[‘REQUEST_URI’];

    if (isset($_GET[‘sli’])) {
    $sli = $_GET[‘sli’];
    if ($sli == ‘fail’) { echo “

    “. $errormsg .”

    “; }
    if ($sli == ‘lost’) { echo “

    “. $lostmsg .”

    “; }
    }

    if (is_user_logged_in()) {
    _e( ‘Howdy’, ‘helfsli’ );
    echo $user_login, ‘. Logout‘;
    } else {
    wp_login_form(array( ‘value_remember’ => 1, ‘redirect’ => $redirect));

    if ( $show_reg && get_option(‘users_can_register’) ) {echo wp_register(”, ”);}
    if ( $show_reg && $show_for) {echo ‘ | ‘;}
    if ( $show_for) {echo ‘Lost Password‘;}

    }

    /* After widget (defined by themes). */
    echo $after_widget;
    }

    function update( $new_instance, $old_instance ) {
    $instance = $old_instance;

    /* Strip tags (if needed) and update the widget settings. */
    $instance[‘title’] = strip_tags( $new_instance[‘title’] );
    $instance[‘errormsg’] = strip_tags( $new_instance[‘errormsg’] );
    $instance[‘lostmsg’] = strip_tags( $new_instance[‘lostmsg’] );
    $instance[‘show_for’] = $new_instance[‘show_for’];
    $instance[‘show_reg’] = $new_instance[‘show_reg’];
    return $instance;
    }

    function form( $instance ) {

    /* Set up some default widget settings. */
    $defaults = array( ‘title’ => ‘Log In’, ‘errormsg’ => ‘Error: Incorrect username/password’, ‘lostmsg’ => ‘Password reset sent.’, ‘show_for’ => false, ‘show_reg’ => false, ‘show_sex’ => true );
    $instance = wp_parse_args( (array) $instance, $defaults ); ?>


  • SEO: Impossible

    SEO: Impossible

    For someone who thinks SEO is crap, I sure talk about it a lot. Google’s got a new toy: Dissavow links.

    In the wake of Panda, a lot of sites got hit with bad SEO rankings from having crappy backlinks. In specific, I know many WordPress theme developers were hurt, including WPMUDev, because spammers and scammers used their themes. Basically their own popularity bit them in the ass, through no fault of their own save their success. After all, a pretty common question people have is “Do those crappy, low-quality inbound links hurt me?” And most of the time, the answer was no. Except when it did with Panda. At the time, it didn’t seem fair to anyone that your popularity would be detrimental to your SEO, and thus we have Dissavow. (Amusingly enough, Bing got there first.)

    But what does it do? Here’s Matt Cuts explaining this:

    For the rest of us, it lets you say ‘These links are crap and they’re not related to me, so please don’t let them impact my search ranking.’ Many of you are looking confused here, and wondering why they impacted you in the first place. After all, it’s not your responsibility to monitor the quality of sites on the Internet, is it? That’s why Google and Bing make the big bucks. And yet we all know how terrible search results can be, and frankly Google’s blog search is horrible. I have to hand it to Google, though. Search is hard, and crowdsourcing the work of teaching a computer what is and is not spam is actually a good idea.

    Google (and Bing’s) methodology rub me wrong. Now that Google has us doing the work for them, by picking out spammy sites and effectively reporting them, you’d think all is good for the theme world. Alas, not so. I’ve heard rumblings that Google is now asking theme developers to remove backlinks!

    While I don’t feel a theme developer will be broken for this, it will make it much harder for them to promote their works. On the plugin end of things, I’ve had people ask me to remove their plugins because we don’t permit WordPress plugins to show backlinks unless they’re opt-in, and this means the dev can’t make money. Part of why is that you can have hundreds of plugins, but only one active theme. The other part is we feel it looks spammy. Now, so does Google.

    But all that aside, if you want to disavow your backlinks, you can now do it, and the directions aren’t complicated. Click on the disavow link, upload a text file formatted in a certain way, reap benefits. Sounds great, right? What if I told you that Google sends you no confirmation at all? There’s no confirmation, no way to see if what you did worked or not, and worst of all, this could take weeks, if not months, for them to crawl, sort, and re-crawl your sites. During that time, you hear nothing. When it’s done, you hear nothing.

    You do all this work and end up in a vacuous hole of ‘well, there’s that then’ with no assurance of anything at all being done. That caught my attention in a bad way. How can I tell I’ve done the right thing? We’re already being killed by not being able to track encrypted search terms, and now we’re not going to be able to tell if removing the links from the bad people is going to help our SERP?

    This is why I think SEO is full of it. To one degree or another, it’s always been about gaming the system, and tricking search engines into letting you rise to the top. Meta tags trumped quality, and then it was links (because obviously if people link to you, you’re valuable). Now we know people game links, so we remove that, which actually doesn’t hurt as much as you think. See, a lot of your search engine ranking came from the quality of sites that linked back to you. But the most valuable sites (like MediaWiki) have stringent policies and rules about not linking, or linking and using nofollow, to prevent you from getting link-juice. In the case of MediaWiki, it makes sense since anyone can edit it.

    But…

    That just went to prove the system was broken. Blogs (WordPress included) nofollows comment links for the same reason. If the door was open, the spammers would use it and make themselves look more important. And as the tools got smarter and started making those links worthless, the spammers started scraping your quality content, which Google et al had to learn to filter. We’re at the point where links are valueless. It doesn’t matter who links to you anymore, because none of the good sites will give you a lot of value since they’re trying to get rid of the spammers. So why is Google giving any weight to these spammer links?

    If the state of link-relativity is so poor that search engines are asking us to remove backlinks from themes, and also to tell them which links to us are worthless, then all links are more trouble than they’re worth and we need to figure out a better way to measure the usefulness of our sites. What measuring sticks do you use?

  • I’ll be in Tybee!

    There’s an upcoming WordPress Community Summit, and I’ll be attending! I was invited before I was employed here at DreamHost (who is providing lunch, yay!), so now I’m serving two purposes! The first is as a community support leader, and in that auspice, I plan to represent the common user. The second is as DreamHosts’s WordPress Support Manager, and there I will represent the support my company provides you DH users.

    Do you have any topics you’d like to see me address at the meetup? Any annoying WordPress/DreamHost issues taht you’re not sure is WP or DH? Leave a comment and I’ll do my best!

  • Failure Is Always An Option

    Failure Is Always An Option

    Failure is always an option.No matter how hard you try, how well you test, and how smart you are, you are going to screw up. I could probably just close this post saying that, but for some reason, people don’t like to accept failure as an option. We don’t want to do anything but succeed and think that we can get everything right, the first time, and every time.

    “Well … you can’t!” as Mal told Jayne. You can’t get it right every time, and you’re probably never going to get it right the first time, mostly because it is the first time. Failure is an important aspect of progress, which we all know, and we’ve all heard, so I won’t delve into that. What I do what to do is remind you how to move from failure. What are your takeaways and what do you do next?

    When software fails, the first thing you do is look at the error. I like to describe things in the plainest English possible: I entered in my email, clicked ‘submit’ and my webpage turned into a blank white page.

    From experience, I know that a blank white page is often a PHP error, but by presenting it to myself in straightforward terms, I now know what to search for if I didn’t know that already. Search engines have come a long way in a short time, and if I search for ‘wordpress blank white page’ I get a lot of hits about the ‘White Screen of Death.’ Now I’ve learned a new term and I’ll file that away for later searches. Awesome to know. Now that I’ve found what the problem is (PHP) I can look into debugging. I can read the PHP error logs, or in the case of WordPress, turn on debugging to see if anything gets output.

    The point to this is that finding an error is the first step in learning. I take what the error is, what the failure is, and I go forward. Failing isn’t a stop, it’s a pause in the process. Too many people take failure as a sign to stop everything, and while yes, failing does mean you’re doing_it_wrong() somewhere in there (or perhaps you’re not doing it as well as the next guy), and sometimes it does result in scrapping everything and starting over, it remains a sign to look at what you’re doing, not to stop entirely. When you don’t know the software well, or the tools, or anything at all, that initial failure of ‘It’s broken’ can be hard to overcome. The fear of failure keeps you from just taking the next step of ‘What do I do?’

    Wisdom of the Ancients

    Once you’ve sort out what your problem is, learn from your failure and pass it on to the next guy. The reason a lot of people hate forums is that someone asks a question and either never replies, or leaves a ‘fixed’ message with no explanation. That makes it impossible to learn from the fail for the next guy, and you force them to reinvent the wheel.

    I’m all for learning by doing, but progress happens because we share the answers. Pretty much all school is for a lot of people is memorizing the answers, which has it’s place. The rest of us learn the theory from seeing the path. We see the start, the fail, the middle, and the win, and it’s that journey that teaches us where to go next and invent new things.

  • WordPress Cancel Post Button

    WordPress Cancel Post Button

    Someone asked about this in the forums. I can see why folks would find it useful, so here’s a simple addition to add a ‘Cancel Post’ button to your publishing metabox.

    This plugin checks what post-type you’re on and redirects you correctly for pages and CPTs.

    To Install

    Make a file called cancel-button.php and put it in your mu-plugins folder (if you don’t have one, just make it in /wp-content/). In that file, paste the following (yes there’s no ending PHP tag, it’s okay, you don’t need it):

    <?php
    
    /* 
    Plugin Name: Cancel
    Plugin URI: https://halfelf.org/
    Description: Adds a 'cancel' button to posts, next to Publish.
    Version: 1.0
    Author: Ipstenu
    License: GPL2
    
    */
    
    add_action( 'post_submitbox_misc_actions', 'author_in_publish' );
    
    function author_in_publish() {
        $screen = get_current_screen();
        $cancel = get_admin_url();
        if ( $screen->id == 'post') {$cancel = "edit.php"; }
        else { $cancel = "edit.php?post_type=$screen->id";}
        
        echo "<div class=\"misc-pub-section\"><a class=\"button\" href=\"".$cancel."\" id=\"post-preview\">".__('Cancel Post')."</a><input type=\"hidden\" name=\"wp-cancelpost\" id=\"wp-cancelpost\" value=\"\"></div>";
    }
    

    This will add the button for all your sites on a network, if you happen to use Multisite.