• Don’t know what I’m doing wrong. I built a widget that interfaces with experts-exchange.com, allowing an ee member to display a “live” rank indicator right on their blog. It does display among my available widgets, but it doesn’t have a configuration control link. I need that configuration so the user can tell the plugin which profile to grab statistics from.

    The relevant code is shown below. I’ve also made the complete source plus images available at: http://hiremasonwolf.com/ee_badge.zip. Any help would be greatly appreciated. The codex describing widget development was extremely sparse. Most of what I did figure out came from looking at the code for another widget that does work.

    function widget_eebadge_init() {
    if (!function_exists(‘register_sidebar_widget’)) {
    return;
    }
    function widget_eebadge($args) {
    extract($args);
    echo $before_widget . $before_title . $after_title;
    $profile = get_option(‘widget_eebadge’);
    $page = file_get_contents(“http://www.experts-exchange.com/M_$profile.html”);
    //… this section not relevant to question
    ?>
    … this section not relevant to question
    <?php echo $after_widget;
    }
    function widget_eebadge_options()
    {
    $profile = get_option(‘widget_eebadge’);
    $profile = $profile[0];
    if(isset($_POST[‘profile’]))
    {
    if(ereg(‘[0-9]{4,7}’,$_POST[‘profile’]))
    {
    update_options(‘widget_eebadge’, array($_POST[‘profile’]));
    $profile = $_POST[‘profile’];
    }
    else
    {
    echo “<p style=’font-weight:bold;’><span style=’color:red’>Invalid link:</span> The profile link provided should be between 4 and 7 digits and may only contain numbers. Please enter a valid code</p>”;
    }
    }
    echo “<p>Complete the link to your EE profile:<br>http://www.experts-exchange.com/M_<input type=’text’ name=’profile’ value=’$profile’ />.html</p>”;
    }
    register_sidebar_widget(‘Experts Exchange Badge’,’widget_eebadge’);
    register_widget_control(‘Select Profile’,’widget_eebadge_options’, 250, 50);
    }

    add_action(‘plugins_loaded’, ‘widget_eebadge_init’);

Viewing 1 replies (of 1 total)
  • Thread Starter locolobo

    (@locolobo)

    It works now. Apparently, the first argument passed to the function ‘register_widget_control’ must be the same as the first argument passed to ‘register_sidebar_widget’. That makes sense to me now, since how else was WP going to know that my control went with my widget. But it didn’t seem obvious to me before, and it would’ve been nice to find it concretely stated in the widget API.

    If any of the WP site admins read this, please add that little tidbit to the API docs.

Viewing 1 replies (of 1 total)

The topic ‘Widget control does not appear’ is closed to new replies.