/**
 *	Display Album's Images when using shortcode
 */
function nak_gp_shortcode_album_images($atts, $show_albums)
{
    $options = get_option('nak_gp_options');
    // Get user credentials and prefs from database
    $my_picasa = new PicasaAPI($options['username'], $options['password']);
    // Create instance of GoogleAPI class
    if (function_exists('output_album_id')) {
        $album_id = output_album_id();
    }
    // Get album ID
    if (!isset($album_id)) {
        return false;
        exit;
    }
    // Extract the attributes into variables
    extract(shortcode_atts(array('user' => $options['username'], 'pass' => $options['password'], 'max_results' => $options['max_results'], 'thumb_size' => $options['thumb_size'], 'album_thumb_size' => $options['album_thumb_size'], 'max_results' => $options['max_results'], 'max_image_size' => $options['max_image_size']), $atts));
    return $my_picasa->get_album_images_display($album_id, $thumb_size, $max_image_size, $max_results, $GLOBALS['wpPicasa']->page);
}
示例#2
0
/**
 * Display Albums when using shortcode
 *
 *
 *
 */
function nak_gp_shortcode_albums($atts)
{
    global $wpPicasa;
    // Get any specific album ids if shortcode has passed any
    // e.g. [nak_google_picasa_albums show_albums='5218473000700519489,  5218507736478682657 ']
    if (isset($atts['show_albums'])) {
        $show_albums = explode(',', $atts['show_albums']);
        // return array split string on commas
        $show_albums = array_map('trim', $show_albums);
        // remove any white space
    }
    $options = get_option('nak_gp_options');
    // Get the options stored for this install
    extract(shortcode_atts(array('user' => $options['username'], 'pass' => $options['password'], 'max_album_results' => $options['max_album_results'], 'max_results' => $options['max_results'], 'album_thumb_size' => $options['album_thumb_size'], 'album_results_page' => $options['album_results_page']), $atts));
    $my_picasa = new PicasaAPI($options['username'], $options['password']);
    // Create instance of PicasaAPI class
    // Call user albums
    return $user_albums = $my_picasa->get_album_display($max_album_results, $album_thumb_size, strtolower($options['album_results_page']), $show_albums);
}
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     // $wpPicasa 	= new WPPicasa();
     $wpPicasa = $GLOBALS['wpPicasa'];
     $options = get_option('nak_gp_options');
     if (!isset($title)) {
         $title = "Google Picasa Albums";
     }
     echo $args['before_widget'];
     echo $args['before_title'] . "<span>{$title}</span>" . $args['after_title'];
     // Create instance of PicasaAPI class
     if ($my_picasa = new PicasaAPI($options['username'], $options['password'])) {
         // Call user albums
         $user_albums = $my_picasa->get_album_display($options['max_album_results'], $options['album_thumb_size'], strtolower($options['album_results_page']));
     }
     echo $user_albums;
     echo $args['after_widget'];
 }
示例#4
0
function nak_gp_validate_options($input)
{
    $errors = array();
    $valid['username'] = esc_attr($input['username']);
    /* $valid['password']        = md5( esc_attr( $input['password'] ) ); */
    $valid['password'] = esc_attr($input['password']);
    $valid['max_album_results'] = esc_attr($input['max_album_results']);
    $valid['album_thumb_size'] = esc_attr($input['album_thumb_size']);
    $valid['max_results'] = esc_attr($input['max_results']);
    $valid['thumb_size'] = esc_attr($input['thumb_size']);
    $valid['max_image_size'] = esc_attr($input['max_image_size']);
    $valid['album_results_page'] = esc_attr($input['album_results_page']);
    // Make sure user name is not empty
    if ($valid['username'] == '') {
        $errors['username'] = '******';
    }
    if ($valid['password'] == '') {
        $errors['password'] = '******';
    }
    // Validate numbers
    // Make sure Max Album Results is numeric
    if (!is_numeric($valid['max_album_results'])) {
        $errors['max_album_results'] = 'Please enter a number for the number of albums to show on a page.';
    }
    if (!is_numeric($valid['album_thumb_size'])) {
        $errors['album_thumb_size'] = 'Please enter a number in pixels for the album thumbnail size.';
    }
    if (!is_numeric($valid['max_results'])) {
        $errors['max_results'] = 'Please enter a number for the number of results to show on a page.';
    }
    if (!is_numeric($valid['thumb_size'])) {
        $errors['thumb_size'] = 'Please enter a number in pixels for the image thumbnail size.';
    }
    if (!is_numeric($valid['max_image_size'])) {
        $errors['max_image_size'] = 'Please enter a number in pixels for image size in the lightbox (e.g. 600).';
    }
    // Check Zend Framework is available
    if ($my_picasa = new PicasaAPI($options['username'], $options['password'])) {
        // Extra check to test for things like Zend Framework
        if ($my_picasa->preflight_check() == false) {
            $zf_notice = 'Error trying' . ' to access Zend/Loader.php using \'use_include_path\' =' . ' true. Make sure you include Zend Framework in your' . ' include_path which currently contains: ' . ini_get('include_path') . '. ';
            $zf_notice .= 'It can be <a href="http://framework.zend.com/download/webservices" target="_blank">downloaded here</a>.';
            $errors['preflight_check'] = "{$zf_notice}";
        }
    }
    // Display all errors together
    if (count($errors) > 0) {
        $err_msg = '';
        // Display errors
        foreach ($errors as $err) {
            $err_msg .= "{$err}<br><br>";
        }
        add_settings_error('nap_gp_text_string', 'nak_gp_texterror', $err_msg, 'error');
    }
    return $valid;
}