Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0.0 released and ready for test and deploy #15

Merged
merged 3 commits into from
Feb 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 35 additions & 15 deletions pinit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* Plugin URI: https://github.com/deshack/pinit
* Description: Handy plugin that adds Pinterest Follow Button, Pin Widget, Profile Widget and Board Widget to your WordPress site.
* Author: deshack
* Version: 1.0.1
* Version: 2.0.0
* Author URI: http://www.deshack.net
* License: GPLv2 or later
*/

/*=== SETUP
*==============================*/

define( 'PINIT_VERSION', '1.0.1' );
define( 'PINIT_VERSION', '2.0.0' );

// Load text domain
function pit_text_start() {
Expand All @@ -27,7 +27,7 @@ function pit_text_start() {
* @since 1.0.1 Moved from wp_head to wp_footer
*/
function pit_pinit_js() {
echo '<script type="text/javascript" async src="//assets.pinterest.com/js/pinit.js"></script>' . "\n";
echo '<script async defer data-pin-hover="true" data-pin-color="red" data-pin-tall="true" type="text/javascript" async src="//assets.pinterest.com/js/pinit.js"></script>' . "\n";
}
add_action( 'wp_footer', 'pit_pinit_js', 9999 );

Expand All @@ -43,36 +43,56 @@ function pit_admin_scripts() {
/*=== SHORTCODES
*==============================*/

function pit_follow_shortcode( $atts ) {
$atts = extract( shortcode_atts( array(
'url' => 'http://www.pinterest.com/pinterest/',
'text' => 'Follow',
), $atts ) );

return '<a data-pin-do="buttonFollow" href="' . $url . '">' . $text . '</a>';
}

function pit_pin_shortcode( $atts ) {
$atts = extract( shortcode_atts( array(
'url' => 'http://www.pinterest.com/pin/99360735500167749/',
'size' => 'small',
), $atts ) );

return '<a data-pin-do="embedPin" href="' . $url . '"></a>';
if ($size == 'large' || $size == 'medium') {
$width = 'data-pin-width="' . $size . '" ';
}

else {
$width = '';
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a ternary operator in this case.

$width = ($size == 'large' || $size == 'medium') ? sprintf('data-pin-width="%s" ', $size) : '';

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, good point. As I said here I just followed your codebase and made some copy/paste/mods but if you want improve it, I can only agree :)



return '<a data-pin-do="embedPin" ' . $width . 'href="' . $url . '"></a>';
}

function pit_profile_shortcode( $atts ) {
$atts = extract( shortcode_atts( array(
'url' => 'http://www.pinterest.com/pinterest/',
'imgWidth' => '92',
'boxHeight' => '175',
'boxWidth' => 'auto'
'url' => 'https://www.pinterest.com/pinterest/',
'imgwidth' => '80',
'boxheight' => '400',
'boxwidth' => '400',
), $atts ) );

return '<a data-pin-do="embedUser" href="' . $url . '" data-pin-scale-width="' . $imgWidth . '" data-pin-scale-height="' . $boxHeight . '" data-pin-board-width="' . $boxWidth . '"></a>';
return '<a data-pin-do="embedUser" data-pin-board-width="' . $boxwidth . '" data-pin-scale-height="' . $boxheight . '" data-pin-scale-width="' . $imgwidth . '" href="' . $url . '"></a>';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use sprintf() here? The code would be more readable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just followed your codebase and moved some value before href for personal needing but it's good to me if you want use a sprintf() instead! :)

}

function pit_board_shortcode( $atts ) {
$atts = extract( shortcode_atts( array(
'url' => 'http://www.pinterest.com/pinterest/pin-pets/',
'imgWidth' => '92',
'boxHeight' => '175',
'boxWidth' => 'auto'
'url' => 'https://www.pinterest.com/pinterest/pin-tips/',
'imgwidth' => '80',
'boxheight' => '400',
'boxwidth' => '400',
), $atts ) );

return '<a data-pin-do="embedBoard" href="' . $url . '" data-pin-scale-width="' . $imgWidth . '" data-pin-scale-height="' . $boxHeight . '" data-pin-board-width="' . $boxWidth . '"></a>';
return '<a data-pin-do="embedBoard" data-pin-board-width="' . $boxwidth . '" data-pin-scale-height="' . $boxheight . '" data-pin-scale-width="' . $imgwidth . '" href="' . $url . '"></a>';
}

add_shortcode( 'pit-follow', 'pit_follow_shortcode' );
add_shortcode( 'pit-pin', 'pit_pin_shortcode' );
add_shortcode( 'pit-profile', 'pit_profile_shortcode' );
add_shortcode( 'pit-board', 'pit_board_shortcode' );
Expand Down Expand Up @@ -101,7 +121,7 @@ function __construct() {
* @see WP_Widget::widget()
*
* @param array $args. Widget arguments.
* @param rray $instance. Saved values from database.
* @param array $instance. Saved values from database.
*/
public function widget( $args, $instance ) {
extract( $args );
Expand Down
29 changes: 23 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
=== Pinit: Pinterest for WordPress ===
Contributors: deshack, iGenius
Contributors: deshack, codeat, igenius
Donate link: http://www.deshack.net/donate/
Tags: pinterest, badge, embedded pin, pin,embed pin, pinterest badge, embedded profile,embed profile, embedded board, embed board, pinterest follow, widgets, widgets pinterest, widget pinterest, sidebar, social network, shortcodes
Requires at least: 3.5
Tested up to: 4.0
Tested up to: 4.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.txt

Place Pinterest badges everywhere in you WordPress using simple Shortcodes or placing a Widget in your sidebar.
Place Pinterest Buttons, Pins, Boards and Profiles everywhere in you WordPress using simple shortcodes and a fully customizable widget.

== Description ==

This plugin allows you to add Pinterest resources to your site without worrying about codes.
This plugin allows you to add Pinterest resources to your site without worrying about codes. Every image of your website will be automagically pinnable on hover.

Features include:

* Automatically place a "Pin it" button on every image

* Pin Widget
* Profile Widget
* Board Widget

* Pin Shortcode [pit-pin]
* Profile Shortcode [pit-profile]
* Board Shortcode [pit-board]
* Follow Shortcode [pit-follow]

Languages:

Expand All @@ -31,24 +34,38 @@ Languages:
* Serbian (credit: [Ogi Djuraskovic](http://firstsiteguide.com/))
* Lithuanian (credit: [shookees](https://github.com/shookees))

[Demo](http://codeat.co/pinit/) - [Shortcode Docs](http://codeat.co/pinit/simple-shortcodes/) - [GitHub](https://github.com/deshack/pinit)

== Installation ==

1. Download and extract the plugin's archive.
2. Put the extracted folder in `/wp-content/plugins`.
3. Activate the plugin in the WordPress Admin.

Or simply install it from the WP Admin Plugins section.
Or simply install it from the WordPress Dashboard Plugins section searching for "Pinit".

== Frequently Asked Questions ==

= I installed and activated the plugin, but I can't see any configuration page. =

Pinit doesn't need any configuration or options page: you can handle every widget directly. Just go under Appearance > Widgets and add your Pinit Widgets to the preferred sidebar.
Pinit doesn't need any configuration or options page: you can handle every widget directly. Just go under Appearance > Widgets and add your Pinit Widgets to the preferred sidebar or use one of the provided shortcodes directly into your content.

== Screenshots ==

1. Pinit Widget
2. Pinit Pin Shortcode
3. Pinit Profile Shortcode
4. Pinit Board Shortcode
5. Pin It Button on site images

== Changelog ==

= 2.0.0 =
* Size choice for Pin shortcode
* Automatically add a "Pin it" button on site images
* Follow Button Shortcode introduced
* Case sensitive attributes for shortcodes replaced

= 1.0.1 =
* Added Lithuanian translation (credit: [shookees](https://github.com/shookees))
* JavaScript moved at the end of `wp_footer`
Expand Down