Plugin Directory

Changeset 482762


Ignore:
Timestamp:
12/31/2011 01:19:39 PM (14 years ago)
Author:
sebstein
Message:

version: 1.1.0

  • feature: set length of title of imported posts
  • docs: extended list of frequently asked questions
Location:
g-crossposting/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • g-crossposting/trunk/admin.php

    r445382 r482762  
    5757    // add field for each option
    5858    add_settings_field('g_crossposting_gplusid', __('Your Google+ ID'), 'g_crossposting_gplusid_field', 'g_crossposting', 'g_crossposting_section_main');
    59     // https://code.google.com/apis/console/
    6059    add_settings_field('g_crossposting_apikey', __('Your Google API key'), 'g_crossposting_apikey_field', 'g_crossposting', 'g_crossposting_section_main');
    6160    add_settings_field('g_crossposting_user', __('Wordpress user to set as author of imported Google+ activities'), 'g_crossposting_author_field', 'g_crossposting', 'g_crossposting_section_options');
     
    6362    add_settings_field('g_crossposting_comment', __('Enable comments on imported Google+ activities'), 'g_crossposting_comment_field', 'g_crossposting', 'g_crossposting_section_options');
    6463    add_settings_field('g_crossposting_maxactivities', __('Maximum number of new activities to import'), 'g_crossposting_maxactivities_field', 'g_crossposting', 'g_crossposting_section_options');
     64    add_settings_field('g_crossposting_titlelen', __('Maximum length of imported title (set to 0 for full length)'), 'g_crossposting_titlelen_field', 'g_crossposting', 'g_crossposting_section_options');
    6565    add_settings_field('g_crossposting_addcanonical', __('Add canonical meta tag pointing to Google+'), 'g_crossposting_addcanonical_field', 'g_crossposting', 'g_crossposting_section_options');
    6666}
     
    8888    $options = get_option('g_crossposting_options');
    8989    echo "<input id='g_crossposting_maxactivities' name='g_crossposting_options[maxactivities]' size='59' maxlength='3' type='text' value='{$options['maxactivities']}' />";
     90}
     91
     92/**
     93 *  output the input field for the maximum length of post title
     94 */
     95function g_crossposting_titlelen_field() {
     96    $options = get_option('g_crossposting_options');
     97    echo "<input id='g_crossposting_titlelen' name='g_crossposting_options[titlelen]' size='59' maxlength='3' type='text' value='{$options['titlelen']}' />";
    9098}
    9199
     
    190198        $new_input['maxactivities'] = 1;
    191199        g_crossposting_add_error('g_crossposting_err_maxactivities', __("The maximum number of activities to import must be a number between 1 and 100."));
     200    }
     201
     202    // validate maximum length of title field
     203    $new_input['titlelen'] = trim($input['titlelen']);
     204    if (! g_crossposting_check_titlelen($new_input['titlelen'])) {
     205        $new_input['titlelen'] = 0;
     206        g_crossposting_add_error('g_crossposting_err_titlelen', __("The maximum length of post title should be a number between 0 and 100."));
    192207    }
    193208
  • g-crossposting/trunk/gplus-crosspost.php

    r445383 r482762  
    44    Plugin URI: http://wordpress.org/extend/plugins/g-crossposting/
    55    Description: Imports your public Google+ activities in your Wordpress blog.
    6     Version: 1.0.1
     6    Version: 1.1.0
    77    Author: Sebastian Stein
    88    Author URI: http://sebstein.hpfsc.de/
     
    175175    // go on validating remaining settings
    176176    if (! g_crossposting_check_maxactivities($options['maxactivities'])) {
     177        return FALSE;
     178    }
     179
     180    if (! g_crossposting_check_titlelen($options['titlelen'])) {
    177181        return FALSE;
    178182    }
     
    323327
    324328        // set title for post
    325         // TODO Make this a setting?
    326329        if ($activity->title) {
    327             $post_title = substr($activity->title, 0, 35).'&hellip;';
     330            $post_title = $activity->title;
    328331        } else if ($att_title) {
    329             $post_title = substr($att_title, 0, 35).'&hellip;';
     332            $post_title = $att_title;
    330333        } else {
    331334            $post_title = 'Google+ post: No title available&hellip;';
     335        }
     336        // shorten post title if required
     337        if ($options['titlelen'] > 0 && strlen($post_title) > $options['titlelen']) {
     338            $post_title = substr($post_title, 0, $options['titlelen']).'&hellip;';
    332339        }
    333340
     
    405412
    406413/**
     414 *  maximum length of post title to import
     415 *
     416 *  @return true if this is set to a number from 0 to 100
     417 */
     418function g_crossposting_check_titlelen($given_titlelen) {
     419    // must be number from 0 to 100
     420    if (!is_numeric($given_titlelen) || $given_titlelen < 0 || $given_titlelen > 100) {
     421        return FALSE;
     422    }
     423
     424    return TRUE;
     425}
     426
     427/**
    407428 *  simple binary option whether canonical tag should be added
    408429 *
  • g-crossposting/trunk/readme.txt

    r445383 r482762  
    44Tags: google, googleplus, posts
    55Requires at least: 3.0.0
    6 Tested up to: 3.2.1
    7 Stable tag: 1.0.1
     6Tested up to: 3.3.0
     7Stable tag: 1.1.0
    88
    99Imports your public Google+ activities in your Wordpress blog.
     
    50501. There you are, it is written next to the API key label.
    5151
    52 It might be that there no key yet, but a button to generate one. In that case,
    53 click the button first. There should also be a *Generate new key* link on this
    54 page.
     52It might be that there is no key yet, but a button to generate one. In that
     53case, click the button first. There should also be a *Generate new key* link on
     54this page.
     55
     56Important: Don't forget to activate your key! It is not enough to just generate
     57one, but you need to activate it on those Google pages, too.
     58
     59= I can't set my Google+ ID or Google API key in the setting form. Why do they disappear? =
     60
     61After you entered a Google+ ID or Google API key in the settings form of this
     62plugin and confirm your change, the plugin will try to access your public
     63Google+ profile. For this purpose, it uses the Google+ ID and the Google API key
     64you provided. If access fails, one of both or even both of them must be wrong.
     65However, the plugin can't determine which one is wrong. Therefore, it removes
     66both settings again to show you that something must have been wrong.
     67
     68= Everything is set up properly, but it doesn't import anything? =
     69
     70This plugin only imports your public Google+ activities. It won't access your
     71private posts on Google+, which you only shared with some circles. If you have
     72never posted anything in public, this plugin won't import anything to your blog.
     73
     74This should prevent that people make something public by accident. If you want
     75something to also appear in your blog, make sure to share it with the public
     76first!
     77
     78= Post titles are still shortened, even if I set length to 0 (meaning unlimited length)? =
     79
     80Google+ itself limits the length of a post title. If you set 0 for the length of
     81the post title, the plugin will import the whole title provided by Google+. If
     82Google+ shortens your title, there is nothing this plugin can do.
    5583
    5684== Screenshots ==
     
    5987
    6088== Changelog ==
     89
     90= 1.1.0 =
     91* make sure to post on Google+ that you are using this plugin!!!
     92* feature: set length of title of imported posts
     93* docs: extended list of frequently asked questions
    6194
    6295= 1.0.1 =
Note: See TracChangeset for help on using the changeset viewer.