Le-mina / ljxp

Automatically exported from code.google.com/p/ljxp
0 stars 0 forks source link

Crossposting not working to LJ #145

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Don't know. I suppose I could do a post and not see it come up on 
LiveJournal.
2.
3.

What is the expected output? What do you see instead?

I expect to see my WP posts crosspost to LJ. What I see instead is nothing. 
Nothing has crossposted since July 29th. I've messed with the settings thinking 
the logging out from the DDnS attack was to blame. Nothing happened when I 
posted today.

What version of the plugin are you using? What version of WordPress?

Plugin Version 2.2.1
WordPress version 3.2.1

Please provide any additional information below.

Original issue reported on code.google.com by rhondaes...@gmail.com on 10 Aug 2011 at 8:58

GoogleCodeExporter commented 8 years ago
It doesn't show any error messages? Very weird. If you don't mind, open up 
lj-xp-options.php and find this line (183 or thereabouts, if you're using an 
editor that shows line numbering):

<!--    <pre><?php //print_r($options); ?></pre> --> 

Change it to this:

<pre><?php print_r($options); ?></pre>

Then save your options. It'll display a list of options and their stored values 
in the database. Things to look for:

- Is the username filled in?
- Is the password filled in? (It should be a long-ish line of junk; it's 
encrypted.)
- Is [crosspost] set to 1?
- Is there anything in the [skip_cats] array?

If you want, just copy the whole mess -- you can remove the password line -- 
and paste it back here, and I'll take a look.

Original comment by st...@sillybean.net on 11 Aug 2011 at 12:31

GoogleCodeExporter commented 8 years ago
The fields on my WP plugin setting pages has user name and password filled
in and saved.

This is what the code looks like:
<?php
// set defaults
function ljxp_get_options() {
    $defaults = array(
            'host'              =>
'www.livejournal.com',
            'username'          => '',
            'password'          => '',
            'custom_name_on'    => 0,
            'custom_name'       => '',
            'crosspost'         => 1,
            'content'           => 'full',
            'privacy'           => 'public',
            'privacy_private'   => 'no_lj',
            'comments'          => 0,
            'tag'               => '1',
            'more'              => 'link',
            'community'         => '',
            'skip_cats'         => array(),
            'header_loc'        => 0,       // 0 means
top, 1 means bottom
            'custom_header'     => '',
            'userpics'          => array(),
            'cut_text'          => __('Read the rest
of this entry »', 'lj-xp'),
    );

    $options = get_option('ljxp');
    if (!is_array($options)) $options = array();

    // clean up options from old versions
    $old_options = get_option('ljxp_username');
    if (!empty($old_options)) {
        $old_option_list = array(   
                    'ljxp_host',
                    'ljxp_username',
                    'ljxp_password',
                    'ljxp_crosspost',
                    'ljxp_custom_name_on',
                    'ljxp_custom_name',
                    'ljxp_privacy',
                    'ljxp_comments',
                    'ljxp_tag',
                    'ljxp_more',
                    'ljxp_community',
                    'ljxp_skip_cats',
                    'ljxp_header_loc',
                    'ljxp_custom_header',
                    'ljxp_delete_private',
                    'ljxp_userpics',
                    'ljxp_cut_text',
                    );
        $old_options = array();
        foreach ($old_option_list as $_opt ) {
            $newkey = str_replace('ljxp_', '', (string)$_opt);
            $old_options[$newkey] = get_option($_opt);
            delete_option($_opt);
        } 
        if (is_array($old_options))
            $options = array_merge( $old_options, $options );
    }

    // still need to get the defaults for the new settings, so we'll
merge again
    return array_merge( $defaults, $options );
}

// Validation/sanitization. Add errors to $msg[].
function ljxp_validate_options($input) {
    $msg = array();
    $linkmsg = '';
    $msgtype = 'error';
    $options = ljxp_get_options();

    // save password no matter what
    if (!isset($input['password']) || empty($input['password']))
        $input['password'] = $options['password']; // preserve!
    else
        $input['password'] = md5($input['password']);

    // If we're handling a submission, save the data
    if(isset($input['update_ljxp_options']) ||
isset($input['crosspost_all']) || isset($input['delete_all'])) {

        if (isset($input['delete_all'])) {
            // If we need to delete all, grab a list of all
entries that have been crossposted
            $beenposted = get_posts(array('meta_key' => 'ljID',
'post_type' => 'any', 'post_status' => 'any', 'numberposts' => '-1'));
            foreach ($beenposted as $post) {
                $repost_ids[] = $post->ID;
            }
            $msg[] .= ljxp_delete_all($repost_ids);
        }

        $input['skip_cats'] = array_diff(get_all_category_ids(),
(array)$input['category']);

        unset($input['category']);

        // trim and stripslash
        if (!empty($input['host']))
$input['host'] =            trim($input['host']);
        if (!empty($input['username']))     $input['username'] =
trim($input['username']);
        if (!empty($input['community']))    $input['community']
=       trim($input['community']);
        if (!empty($input['custom_name']))
$input['custom_name'] =     trim(stripslashes($input['custom_name']));
        if (!empty($input['custom_header'])) $input['custom_header']
=   trim(stripslashes($input['custom_header']));

        if(isset($input['crosspost_all'])) {
            $msg[] .= ljxp_post_all();
        }

    } // if updated
    unset($input['delete_all']);
    unset($input['crosspost_all']);
    unset($input['update_ljxp_options']);

    // If we are clearing the userpics, then get a new list of userpics
from the server.
    if (isset($input['clear_userpics'])) {
        $input['userpics'] = array();
        $msg[] .= __('Userpic list cleared.', 'lj-xp');
        $msgtype = 'updated';
        unset($input['clear_userpics']);
    }
    elseif (isset($input['update_userpics'])) {
        $pics = ljxp_update_userpics($input['username']);
        $input['userpics'] = $pics['userpics'];
        $msg[] .= $pics['msg'];
        $msgtype = $pics['msgtype'];
        unset($input['update_userpics']);
    }
    else
        $input['userpics'] = $options['userpics']; // preserve

    // Send custom updated message
    $msg = implode('<br />', $msg);

    if (empty($msg)) {
        $msg = __('Settings saved.', 'lj-xp');
        $msgtype = 'updated';
    }

    add_settings_error( 'ljxp', 'ljxp', $msg, $msgtype );
    return $input;
}

// ---- Options Page -----

function ljxp_add_pages() {
    $pg = add_options_page("LiveJournal", "LiveJournal",
'manage_options', basename(__FILE__), 'ljxp_display_options');
    add_action("admin_head-$pg", 'ljxp_settings_css');
    // register setting
    add_action( 'admin_init', 'register_ljxp_settings' );

    // Help screen 
    $text = '<h3>'.__('How To', 'lj-xp')."</h3>
    <ul>
        <li>" . sprintf(__('<a href="%s">Add a link to the
LiveJournal post</a> in your WordPress theme', 'lj-xp' ),
'http://code.google.com/p/ljxp/wiki/LinkingToLJ')."</li>        
        <li>" . sprintf(__('<a href="%s">Add custom fields</a>
([foo]) to the crosspost header or footer', 'lj-xp' ),
'http://code.google.com/p/ljxp/wiki/CustomHeaderFields')."</li>
        <li>" . sprintf(__('<strong>Tip:</strong> If LJ has been
down for a while and you just need to crosspost your last few entries, <a
href="%s">using Bulk Edit</a> is much faster than the Crosspost All
button.', 'lj-xp' ),
'http://code.google.com/p/ljxp/wiki/BulkEditvsCrosspostAll')."</li>
    </ul>";
    $text .= '<h3>' . __( 'More Help', 'lj-xp' ) . '</h3>';

    $text .= '<ul>';
    $text .= '<li><a href="http://code.google.com/p/ljxp/">' . __(
'Plugin Home Page', 'lj-xp' ) . '</a></li>';
    $text .= '<li><a href="http://code.google.com/p/ljxp/issues/list">'
. __( 'Bug Tracker', 'lj-xp' ) . '</a> — report problems here</li>';
    $text .= '</ul>';

    add_contextual_help( $pg, $text );  
}

// Add link to options page from plugin list
add_action('plugin_action_links_' . plugin_basename(__FILE__),
'lj_xp_plugin_actions');
function lj_xp_plugin_actions($links) {
    $new_links = array();
    $new_links[] = '<a
href="options-general.php?page=lj_crosspost.php">' . __('Settings',
'google-analyticator') . '</a>';
    return array_merge($new_links, $links);
}

// Display the options page
function ljxp_display_options() {
?>
<div class="wrap">
    <form method="post" id="ljxp" action="options.php">
        <?php 
        settings_fields('ljxp');
        get_settings_errors( 'ljxp' );  
        settings_errors( 'ljxp' );
        $options = ljxp_get_options();
        ?>
        <h2><?php _e('LiveJournal Crossposter Options', 'lj-xp');
?></h2>
        <!--    <pre><?php //print_r($options); ?></pre>   -->
        <table class="form-table ui-tabs-panel">
            <tr valign="top">
                <th scope="row"><?php
_e('LiveJournal-compliant host:', 'lj-xp') ?></th>
                <td><input name="ljxp[host]" type="text"
id="host" value="<?php esc_attr_e($options['host']); ?>" size="40" /><br />
                <span class="description">
                <?php
                _e('If you are using a LiveJournal-compliant
site other than LiveJournal (like DeadJournal), enter the domain name here.
LiveJournal users can use the default value', 'lj-xp');
                ?>
                </span>
                </td>
            </tr>
            <tr valign="top">
                <th scope="row"><?php _e('LJ Username',
'lj-xp'); ?></th>
                <td><input name="ljxp[username]" type="text"
id="username" value="<?php esc_attr_e($options['username']); ?>" size="40"
/></td>
            </tr>
            <tr valign="top">
                <th scope="row"><?php _e('LJ Password',
'lj-xp'); ?></th>
                <td><input name="ljxp[password]"
type="password" id="password" size="40" /><br />
                <span  class="description"><?php
                _e('Only enter a value if you wish to change
the stored password. Leaving this field blank will not erase any passwords
already stored.', 'lj-xp');
                ?></span>
                </td>
            </tr>
            <tr valign="top">
                <th scope="row"><?php _e('Community',
'lj-xp'); ?></th>
                <td><input name="ljxp[community]"
type="text" id="community" value="<?php esc_attr_e($options['community']);
?>" size="40" /><br />
                <span class="description"><?php
                _e("If you wish your posts to be copied to a
community, enter the community name here. Leaving this space blank will copy
the posts to the specified user's journal instead", 'lj-xp');
                ?></span>
                </td>
            </tr>
        </table>
        <fieldset class="options">
            <legend><h3><?php _e('Crosspost Default', 'lj-xp');
?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php _e('If no
crosspost setting is specified for an individual post:', 'lj-xp'); ?></th>
                    <td>
                    <label>
                        <input
name="ljxp[crosspost]" type="radio" value="1" <?php
checked($options['crosspost'], 1); ?>/>
                        <?php _e('Crosspost',
'lj-xp'); ?>
                    </label>
                    <br />
                    <label>
                        <input
name="ljxp[crosspost]" type="radio" value="0" <?php
checked($options['crosspost'], 0); ?>/>
                        <?php _e('Do not crosspost',
'lj-xp'); ?>
                    </label>
                </tr>
                <tr valign="top">
                    <th scope="row"><?php _e('Content to
crosspost:', 'lj-xp'); ?></th>
                    <td>
                    <label>
                        <input name="ljxp[content]"
type="radio" value="full" <?php checked($options['content'], 'full'); ?>/>
                        <?php _e('Full text',
'lj-xp'); ?>
                    </label>
                    <br />
                    <label>
                        <input name="ljxp[content]"
type="radio" value="excerpt" <?php checked($options['content'], 'excerpt');
?>/>
                        <?php _e('Excerpt only',
'lj-xp'); ?>
                    </label>
                </tr>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('Blog Header', 'lj-xp');
?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php _e('Crosspost
header/footer location', 'lj-xp'); ?></th>
                    <td>
                    <label>
                        <input
name="ljxp[header_loc]" type="radio" value="0" <?php
checked($options['header_loc'], 0); ?>/>
                        <?php _e('Top of post',
'lj-xp'); ?>
                    </label>
                    <br />
                    <label>
                        <input
name="ljxp[header_loc]" type="radio" value="1" <?php
checked($options['header_loc'], 1); ?> /> 
                        <?php _e('Bottom of post',
'lj-xp'); ?>
                    </label></td>
                </tr>
                <tr valign="top">
                    <th scope="row"><?php _e('Set blog
name for crosspost header/footer', 'lj-xp'); ?></th>
                    <td>
                        <label>
                            <input
name="ljxp[custom_name_on]" type="radio" value="0" <?php
checked($options['custom_name_on'], 0); ?>
                            onclick="javascript:
jQuery('#custom_name_row').hide('fast');"/>
                            <?php printf(__('Use
the title of your blog (%s)', 'lj-xp'), get_option('blogname')); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[custom_name_on]" type="radio" value="1" <?php
checked($options['custom_name_on'], 1); ?> 
                            onclick="javascript:
jQuery('#custom_name_row').show('fast');"/>
                            <?php _e('Use a
custom title', 'lj-xp'); ?>
                        </label>
                    </td>
                </tr>
                <tr valign="top" id="custom_name_row" <?php
if ($options['custom_name_on']) echo 'style="display: table-row"'; else echo
'style="display: none"'; ?>>
                    <th scope="row"><?php _e('Custom
blog title', 'lj-xp'); ?></th>
                    <td><input name="ljxp[custom_name]"
type="text" id="custom_name" value="<?php
esc_attr_e($options['custom_name']); ?>" size="40" /><br />
                    <span class="description"><?php
                    _e('If you chose to use a custom
title above, enter the title here. This will be used in the header which
links back to this site at the top of each post on the LiveJournal.',
'lj-xp');
                    ?></span>
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row"><?php _e('Custom
crosspost header/footer', 'lj-xp'); ?></th>
                    <td><textarea
name="ljxp[custom_header]" id="custom_header" rows="3" cols="40"><?php echo
esc_textarea($options['custom_header']); ?></textarea><br />
                    <span  class="description"><?php
                    _e("If you wish to use LJXP's
dynamically generated post header/footer, you can ignore this setting. If
you don't like the default crosspost header/footer, specify your own here.
For flexibility, you can choose from a series of case-sensitive substitution
strings, listed below:", 'lj-xp');
                    ?></span>
                    <dl>
                        <dt>[blog_name]</dt>
                        <dd><?php _e('The title of
your blog, as specified above', 'lj-xp'); ?></dd>

                        <dt>[blog_link]</dt>
                        <dd><?php _e("The URL of
your blog's homepage", 'lj-xp'); ?></dd>

                        <dt>[permalink]</dt>
                        <dd><?php _e('A permanent
URL to the post being crossposted', 'lj-xp'); ?></dd>

                        <dt>[comments_link]</dt>
                        <dd><?php _e('The URL for
comments. Generally this is the permalink URL with #comments on the end',
'lj-xp'); ?></dd>

                        <dt>[tags]</dt>
                        <dd><?php _e('Tags with
links list for the post', 'lj-xp'); ?></dd>

                        <dt>[categories]</dt>
                        <dd><?php _e('Categories
with links list for the post', 'lj-xp'); ?></dd>

                        <dt>[comments_count]</dt>
                        <dd><?php _e('An image
containing a comments counter', 'lj-xp'); ?></dd>

                        <dt>[author]</dt>
                        <dd><?php _e('The display
name of the post\'s author', 'lj-xp'); ?></dd>
                    </dl>
                    <span class="description"><?php
printf(__('You can also <a href="%s">define your own fields</a>.', 'lj-xp'),
'http://code.google.com/p/ljxp/wiki/CustomHeaderFields'); ?></span>
                    </td>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('Post Privacy', 'lj-xp');
?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php
_e('LiveJournal privacy level for all published WordPress posts', 'lj-xp');
?></th>
                    <td>
                        <label>
                            <input
name="ljxp[privacy]" type="radio" value="public" <?php
checked($options['privacy'], 'public'); ?>/>
                            <?php _e('Public',
'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[privacy]" type="radio" value="private" <?php
checked($options['privacy'], 'private'); ?> />
                            <?php _e('Private',
'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[privacy]" type="radio" value="friends" <?php
checked($options['privacy'], 'friends'); ?>/>
                            <?php _e('Friends
only', 'lj-xp'); ?>
                        </label>
                        <br />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row"><?php
_e('LiveJournal privacy level for all private WordPress posts', 'lj-xp');
?></th>
                    <td>
                        <label>
                            <input
name="ljxp[privacy_private]" type="radio" value="public" <?php
checked($options['privacy_private'], 'public'); ?>/>
                            <?php _e('Public',
'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[privacy_private]" type="radio" value="private" <?php
checked($options['privacy_private'], 'private'); ?> />
                            <?php _e('Private',
'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[privacy_private]" type="radio" value="friends" <?php
checked($options['privacy_private'], 'friends'); ?>/>
                            <?php _e('Friends
only', 'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[privacy_private]" type="radio" value="no_lj" <?php
checked($options['privacy_private'], 'no_lj'); ?>/>
                            <?php _e('Do not
crosspost at all', 'lj-xp'); ?>
                        </label>
                        <br />
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('LiveJournal Comments',
'lj-xp'); ?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php _e('Should
comments be allowed on LiveJournal?', 'lj-xp'); ?></th>
                    <td>
                    <label>
                        <input name="ljxp[comments]"
type="radio" value="0" <?php checked($options['comments'], 0); ?>/>
                        <?php _e('Require users to
comment on WordPress', 'lj-xp'); ?>
                    </label>
                    <br />
                    <label>
                        <input name="ljxp[comments]"
type="radio" value="1" <?php checked($options['comments'], 1); ?>/>
                        <?php _e('Allow comments on
LiveJournal', 'lj-xp'); ?>
                    </label>
                    <br />
                </tr>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('LiveJournal Tags', 'lj-xp');
?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php _e('Tag
entries on LiveJournal?', 'lj-xp'); ?></th>
                    <td>
                        <?php
                            /* PHP-only comment:
                             *
                             * Yes, 1 -> 3 -> 2
-> 0 is a wierd order, but
                             * if categories = 1
and tags = 2,
                             * nothing would
equal 0
                             * and
                             * tags+categories =
3
                             */
                        ?>
                        <label>
                            <input
name="ljxp[tag]" type="radio" value="1" <?php checked($options['tag'], 1);
?>/>
                            <?php _e('Tag
LiveJournal entries with WordPress categories only', 'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[tag]" type="radio" value="3" <?php checked($options['tag'], 3);
?>/>
                            <?php _e('Tag
LiveJournal entries with WordPress categories and tags', 'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[tag]" type="radio" value="2" <?php checked($options['tag'], 2);
?>/>
                            <?php _e('Tag
LiveJournal entries with WordPress tags only', 'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[tag]" type="radio" value="0" <?php checked($options['tag'], 0);
?>/>
                            <?php _e('Do not tag
LiveJournal entries', 'lj-xp'); ?>
                        </label>
                        <br />
                        <span class="description">
                        <?php
                        _e('You may with to disable
this feature if you are posting in an alphabet other than the Roman
alphabet. LiveJournal does not seem to support non-Roman alphabets in tag
names.', 'lj-xp');
                        ?>
                        </span>
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('Handling of
<!--More-->', 'lj-xp'); ?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php _e('How should
LJXP handle More tags?', 'lj-xp'); ?></th>
                    <td>
                        <label>
                            <input
name="ljxp[more]" type="radio" value="link" <?php checked($options['more'],
'link'); ?>/>
                            <?php _e('Link back
to WordPress', 'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[more]" type="radio" value="lj-cut" <?php
checked($options['more'], 'lj-cut'); ?>/>
                            <?php _e('Use an
lj-cut', 'lj-xp'); ?>
                        </label>
                        <br />
                        <label>
                            <input
name="ljxp[more]" type="radio" value="copy" <?php checked($options['more'],
'copy'); ?>/>
                            <?php _e('Copy the
entire entry to LiveJournal', 'lj-xp'); ?>
                        </label>
                        <br />
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('Category Selection', 'lj-xp');
?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php _e('Select
which categories should be crossposted', 'lj-xp'); ?></th>
                    <td>
                        <ul id="category-children">
                            <li><label
class="selectit"><input type="checkbox" class="checkall"> 
                                <em><?php
_e("Check all", 'lj-xp'); ?></em></label></li>
                            <?php
                            if
(!is_array($options['skip_cats'])) $options['skip_cats'] =
(array)$options['skip_cats'];
                            $selected =
array_diff(get_all_category_ids(), $options['skip_cats']);

//wp_category_checklist(0, 0, $selected, false, 0, false);

wp_category_checklist(0, 0, $selected, false, $walker = new
LJXP_Walker_Category_Checklist, false);
                            ?>
                        </ul>
                    <span class="description">
                    <?php _e('Any post that has <em>at
least one</em> of the above categories selected will be crossposted.'); ?>
                    </span>
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('Userpics', 'lj-xp');
?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"><?php _e('The
following userpics are currently available', 'lj-xp'); ?></th>
                    <td>
                    <?php
                        $userpics =
$options['userpics'];
                        if (empty($userpics))
                            _e('<p>No userpics
have been downloaded, only the default will be available.</p>');
                        else
                            echo implode(', ',
$userpics);
                    ?>
                    <br/>
                    <br/>
                    <input type="submit"
name="ljxp[update_userpics]" value="<?php esc_attr_e('Update Userpics',
'lj-xp'); ?>" class="button-secondary" />

                    <?php if
(count($options['userpics'])) { ?>
                        <input type="submit"
name="ljxp[clear_userpics]" value="<?php printf(esc_attr('Clear %d
Userpics', 'lj-xp'), count($options['userpics'])); ?>"
class="button-secondary" />
                    <?php } ?>
                    </td>
                </tr>
            </table>
        </fieldset>
        <fieldset class="options">
            <legend><h3><?php _e('Crosspost or delete all
entries', 'lj-xp'); ?></h3></legend>
            <table class="form-table ui-tabs-panel">
                <tr valign="top">
                    <th scope="row"> </th>
                    <td>
                    <?php printf(__('If you have changed
your username or community, you might want to crosspost all your entries, or
delete all the old ones from your journal. These buttons are hidden so you
don\'t press them by accident. <a href="%s" %s>Show the buttons.</a>',
'lj-xp'), '#scary-buttons', 'onclick="javascript:
jQuery(\'#scary-buttons\').show(\'fast\');"'); ?>
                    </td>
                </tr>
                <tr valign="top" id="scary-buttons">
                    <th scope="row"> </th>
                    <td>
                    <input type="submit"
name="ljxp[crosspost_all]" id="crosspost_all" value="<?php
esc_attr_e('Update options and crosspost all WordPress entries', 'lj-xp');
?>" class="button-secondary" />
                    <input type="submit"
name="ljxp[delete_all]" id="delete_all" value="<?php esc_attr_e('Update
options and delete all journal entries', 'lj-xp'); ?>"
class="button-secondary" />
                    </td>
                </tr>
            </table>
        </fieldset>
        <p class="submit">
            <input type="submit"
name="ljxp[update_ljxp_options]" value="<?php esc_attr_e('Update Options');
?>" class="button-primary" />
        </p>
    </form>
    <script type="text/javascript">
    jQuery(document).ready(function($){
        $(function () { // this line makes sure this code runs on
page load
            $('.checkall').click(function () {

$(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked',
this.checked);
            });
        });
    });
    </script>
</div>
<?php
}

function ljxp_update_userpics($username) {
    $msgtype = 'error';

    // We keep a flag if we should keep processing since there are
multiple steps here
    $keep_going = 1;

    // Userpics can be found from the user's domain, in an atom feed
    if (empty($username)) {
        // Report what we did to the user
        $msg[] .= __('Cannot update userpic list unless username is
set.', 'lj-xp');
        $keep_going = 0;
    }

    // Download the Atom feed from the server.
    if ($keep_going) {
        $atom_data = wp_remote_get('http://' . $username .
'.livejournal.com/data/userpics');

        if( is_wp_error( $atom_data ) ) {
            $msg[] .= __('Cannot download Atom feed of userpics.',
'lj-xp');
            $keep_going = 0;
        }
        /* // DEBUG
        else {
           $msg[] .= 'Response:<pre>';
           $msg[] .= print_r( $atom_data, true );
           $msg[] .= '</pre>';
        }
        /**/
    }

    // Parse the Atom feed and pull out the keywords
    if ($keep_going) {
        $new_userpics = array();

        try {
            // Parse the data as an XML string. The atom feed
has many fields, but the category/@term
            // contains the name that is placed in the post
metadata
            // and content/@src contains the URL
            $atom_doc = new SimpleXmlElement($atom_data['body'],
LIBXML_NOCDATA);

            foreach($atom_doc->entry as $entry) {
                $attributes =
$entry->category->attributes();
                $term = $attributes['term'];
//              $content = $entry->content->attributes();
//              $src = $content['src'];
                $new_userpics[] = html_entity_decode($term);
            }
        } catch (Exception $e) {
            $msg[] .= __('Cannot parse Atom data from
LiveJournal.', 'lj-xp');
            $keep_going = 0;
        }
    }

    // Finally, we have new userpics, so we save it in our array
    if ($keep_going) {
        // Sort these so they come in a consistent format.
        sort($new_userpics);

        // Report our success
        $msg[] .= sprintf(__('Found %d userpics on LiveJournal.',
'lj-xp'), count($new_userpics));
        $msgtype = 'updated';
    }
    $msg = implode('<br />', $msg);
    return array('userpics' => $new_userpics, 'msg' => $msg, 'msgtype'
=> $msgtype);
}

// pre-3.1 compatibility
if (!function_exists('esc_textarea')) {
    function esc_textarea( $text ) {
         $safe_text = htmlspecialchars( $text, ENT_QUOTES );
         return apply_filters( 'esc_textarea', $safe_text, $text );
    }
}

// custom walker so we can change the name attribute of the category
checkboxes (until #16437 is fixed)
// mostly a duplicate of Walker_Category_Checklist
class LJXP_Walker_Category_Checklist extends Walker {
     var $tree_type = 'category';
     var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); 

    function start_lvl(&$output, $depth, $args) {
         $indent = str_repeat("\t", $depth);
         $output .= "$indent<ul class='children'>\n";
     }

    function end_lvl(&$output, $depth, $args) {
         $indent = str_repeat("\t", $depth);
         $output .= "$indent</ul>\n";
     }

    function start_el(&$output, $category, $depth, $args) {
         extract($args);
         if ( empty($taxonomy) )
             $taxonomy = 'category';

        // This is the part we changed
         $name = 'ljxp['.$taxonomy.']';

         $class = in_array( $category->term_id, $popular_cats ) ? '
class="popular-category"' : '';
         $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" .
'<label class="selectit"><input value="' . $category->term_id . '"
type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' .
$category->term_id . '"' . checked( in_array( $category->term_id,
$selected_cats ), true, false ) . disabled( empty( $args['disabled'] ),
false, false ) . ' /> ' . esc_html( apply_filters('the_category',
$category->name )) . '</label>';
     }

    function end_el(&$output, $category, $depth, $args) {
         $output .= "</li>\n";
     }
}
?>

Original comment by rhondaes...@gmail.com on 11 Aug 2011 at 12:38

GoogleCodeExporter commented 8 years ago
PS - I've tried re doing my log in information on the fields in WordPress -
that didn't do anything to the code. And I'm not comfortable editing code
without someone telling me it's not going to implode my computer.

Original comment by rhondaes...@gmail.com on 11 Aug 2011 at 12:47

GoogleCodeExporter commented 8 years ago
I don't need the source code for the plugin again; I kind of have that. ;) I 
promise that altered line will not implode your computer, but it will give me 
some information that will be helpful in debugging your problem.

Original comment by st...@sillybean.net on 11 Aug 2011 at 8:54

GoogleCodeExporter commented 8 years ago
I copied the code from the site. I didn't remove anything from it. What do
you want me to do?

Original comment by rhondaes...@gmail.com on 11 Aug 2011 at 9:18

GoogleCodeExporter commented 8 years ago
I had exactly same issue. After uncommenting the print_r output I saw that the 
password field is blank. After reentering the password everything works 
perfectly. Not sure why this happened though - perhaps WPAU did that.

Original comment by emeliya...@gmail.com on 13 Sep 2011 at 2:18

GoogleCodeExporter commented 8 years ago
Hello, I have the same problem right after my WordPress automatically upgraded 
to the latest version. Please let me know if there's an issue with 
compatibility or if the reason why I'm having the "Could not connect to 
http://www.livejournal.com/. This post has not been crossposted. (-32300 : 
transport error - could not open socket)" is due to some compatibility issue?

Thanks.

Original comment by v...@libellecreative.com on 5 Mar 2014 at 5:55

GoogleCodeExporter commented 8 years ago
The -32000 error most often happens when, for whatever reason, you need to 
reenter your LJ password. Go to your LJ-XP settings page, type it in, and save 
your settings. Then see if you can crosspost an entry.

Original comment by st...@sillybean.net on 5 Mar 2014 at 6:07

GoogleCodeExporter commented 8 years ago
This plugin is just flakey. For me, sometimes it posts, sometimes it won't. 
Just now, it worked fine for two posts and balked on the third. Just 
deactivate, re-activate and input your PW again and save. There is definitely 
something going on between the plugin and the LJ servers. Meh. 

Original comment by misang...@gmail.com on 7 May 2014 at 6:14