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

Add Genesis Simple Love #64

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion lib/admin-icon-preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Gensis_Simple_Share_Preview {
function __construct() {

$icons = get_option( 'genesis_simple_share_sort', array(
'main' => 'genesis_simple_share_google_plus,genesis_simple_share_facebook,genesis_simple_share_twitter,genesis_simple_share_pinterest,genesis_simple_share_linkedin,genesis_simple_share_stumbleupon'
'main' => 'genesis_simple_share_google_plus,genesis_simple_share_facebook,genesis_simple_share_twitter,genesis_simple_share_pinterest,genesis_simple_share_linkedin,genesis_simple_share_stumbleupon,genesis_simple_share_love'
) );

$icons = explode( ',', $icons['main'] );
Expand Down Expand Up @@ -70,6 +70,10 @@ function __construct() {
case 'genesis_simple_share_stumbleupon':
$icon_sort[] = 'stumbleupon';
break;

case 'genesis_simple_share_love':
$icon_sort[] = 'love';
break;

}
}
Expand Down Expand Up @@ -171,6 +175,11 @@ function get_icon_output( $location, $icons = array() ){

$data_title = 'Pin';
break;

case 'love' :

$data_title = __('Love', 'genesis-simple-share');
break;

default:

Expand Down
24 changes: 24 additions & 0 deletions lib/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function __construct() {
'pinterest' => 1,
'linkedin' => 1,
'stumbleupon' => 1,
'love' => 1,
)
);

Expand Down Expand Up @@ -174,6 +175,13 @@ function scripts() {
array(),
'0.1.0'
);

$atts = array(
'nonce' => wp_create_nonce( 'genesis_love' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'love_text' => apply_filters( 'genesis_simple_love_text', __( 'Love', 'genesis-simple-share' ) )
);
wp_localize_script( 'genesis-simple-share-plugin-js', 'simple_love', $atts );

}

Expand Down Expand Up @@ -235,6 +243,7 @@ function metaboxes() {
add_meta_box( 'genesis_simple_share_pinterest', __( 'Pinterest', 'genesis-simple-share' ), array( $this, 'pinterest' ), $this->pagehook, 'main' );
add_meta_box( 'genesis_simple_share_linkedin', __( 'Linkedin', 'genesis-simple-share' ), array( $this, 'linkedin' ), $this->pagehook, 'main' );
add_meta_box( 'genesis_simple_share_stumbleupon', __( 'StumbleUpon', 'genesis-simple-share' ), array( $this, 'stumbleupon' ), $this->pagehook, 'main' );
add_meta_box( 'genesis_simple_share_love', __( 'Love', 'genesis-simple-share' ), array( $this, 'love' ), $this->pagehook, 'main' );



Expand Down Expand Up @@ -409,6 +418,21 @@ function linkedin() {
$this->checkbox( $id , __( 'Use this button?', 'genesis-simple-share' ) );

}

/**
* Create Love settings metabox output
*
*
* @since 0.1.0
*
*/
function love() {

$id = 'love';

$this->checkbox( $id , __( 'Use this button?', 'genesis-simple-share' ) );

}

/**
* Outputs select field to select position for the icon
Expand Down
66 changes: 66 additions & 0 deletions lib/ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Create ajax handle for checking cookies
* and updating metadata
*
* @since 1.0.7
* @uses important genesis_simple_love ajax used.
* @param nonce, post_id
* @return json datatype
*/
if( ! class_exists( 'Genesis_Simple_Share_AJAX' ) ){
class Genesis_Simple_Share_AJAX{
function __construct(){
Copy link
Contributor

Choose a reason for hiding this comment

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

please document all functions/methods.

/**
 * Description of function/method.
 *
 * @since 0.1.0
 * @uses important functions/methods used.
 * @param string/array/boolean/mixed $parameter description of parameter
 * @return string/array/boolean/void/mixed
 */

add_action( 'wp_ajax_genesis_simple_love', array( $this, 'ajax_love' ));
add_action( 'wp_ajax_nopriv_genesis_simple_love', array( $this, 'ajax_love' ));
}

function ajax_love() {
$result = array();
$nonce = $_REQUEST['nonce'];
$post_id = url_to_postid( $_REQUEST['data_url'] );
$loved = array();

if ( !wp_verify_nonce( $nonce, 'genesis_love' )) {
exit( 'You don\'t have any power here!' );
}

$handle = '';
if( isset( $_COOKIE['genesis_simple_love'] ) ){
$loved = @unserialize(base64_decode($_COOKIE['genesis_simple_love']));
}

//get love
if( isset( $_REQUEST['data'] ) && 'getCount' == $_REQUEST['data'] ){
echo '{"url":"'. $_REQUEST['data_url'] .'","count":"'. (int) get_post_meta($post_id, '_genesis_simple_love_', true) .'"}';
die();
}

//save love
if ( is_array( $loved ) && !in_array( $post_id, $loved ) ){
$loved[] = $post_id;
$post_loved = (int) get_post_meta($post_id, '_genesis_simple_love_', true);
$post_loved++;
update_post_meta( $post_id, '_genesis_simple_love_', $post_loved );

$_COOKIE['genesis_simple_love'] = base64_encode(serialize($loved));
setcookie( 'genesis_simple_love', $_COOKIE['genesis_simple_love'] , time()+(10*365*24*60*60),'/' );

$result['type'] = 'success';
$result['message'] = apply_filters( 'genesis_simple_love_message', __('Thank You for loving this!', 'genesis-simple-share' ) );
$result['count'] = $post_loved;
$result['id'] = $post_id;
} else {
$post_loved = (int) get_post_meta( $post_id, '_genesis_simple_love_', true );
$result['type'] = 'error';
$result['message'] = apply_filters( 'genesis_simple_loved', __( 'You already loved this. Thanks!', 'genesis-simple-share' ) );
$result['count'] = $post_loved;
$result['id'] = $post_id;
}

echo $result = json_encode( $result );
die();
}
}
new Genesis_Simple_Share_AJAX();
}
4 changes: 3 additions & 1 deletion lib/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@
.genesis_page_genesis_simple_share_settings #genesis_simple_share_pinterest h3.hndle { background: #cb2127; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_linkedin h3.hndle { background: #035a87; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_stumbleupon h3.hndle { background: #eb4923; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_love h3.hndle { background: #ae1319; }

.genesis_page_genesis_simple_share_settings #genesis_simple_share_twitter h3.hndle:before { content: '\f202'; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_facebook h3.hndle:before { content: '\f204'; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_google_plus h3.hndle:before { content: '\f218'; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_pinterest h3.hndle:before { content: '\f209'; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_linkedin h3.hndle:before { content: '\f207'; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_stumbleupon h3.hndle:before { content: '\f223'; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_stumbleupon h3.hndle:before { content: '\f223'; }
.genesis_page_genesis_simple_share_settings #genesis_simple_share_love h3.hndle:before { content: '\f461'; }
13 changes: 13 additions & 0 deletions lib/css/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
.pinterest .share:before { content: '\f209'; }
.linkedin .share:before { content: '\f207'; }
.stumbleupon .share:before { content: '\f223'; }
.love .share:before { content: '\f461'; }

.share-small .pinterest .share:before {
font-size: 12px;
Expand Down Expand Up @@ -316,13 +317,18 @@
.share-filled .stumbleupon .count,
.share-filled .stumbleupon .count:hover { color: #eb4923; border: 1px solid #eb4923; }

.share-filled .love .share { background: #ae1319; }
.share-filled .love .count,
.share-filled .love .count:hover { color: #ae1319; border: 1px solid #ae1319; }

.share-filled .twitter:hover .count { background: #09b0ed !important; }
.share-filled .facebook:hover .count { background: #3d5a98 !important; }
.share-filled .googlePlus:hover .count { background: #dd4c39 !important; }
.share-filled .linkedin:hover .count { background: #035a87 !important; }
.share-filled .youtube:hover .count { background: #cc181e !important; }
.share-filled .pinterest:hover .count { background: #cb2127 !important; }
.share-filled .stumbleupon:hover .count { background: #eb4923 !important; }
.share-filled .love:hover .count { background: #ae1319 !important; }

.share-filled .sharrre:hover .count {
color: #fff;
Expand Down Expand Up @@ -357,6 +363,10 @@
.share-outlined .stumbleupon .count,
.share-outlined .stumbleupon .count:hover { border: 1px solid #eb4923; color: #eb4923; }

.share-outlined .love .share,
.share-outlined .love .count,
.share-outlined .love .count:hover { border: 1px solid #ae1319; color: #ae1319; }

.share-outlined.share-small .share,
.share-outlined.share-medium .share { border-right: none !important; }

Expand Down Expand Up @@ -386,6 +396,9 @@
.share-outlined .stumbleupon:hover .share,
.share-outlined .stumbleupon:hover .count { background: #eb4923; }

.share-outlined .love:hover .share,
.share-outlined .love:hover .count { background: #ae1319; color: #fff; }

.share-outlined .sharrre:hover .count,
.share-outlined .sharrre:hover .share {
color: #fff;
Expand Down
18 changes: 17 additions & 1 deletion lib/front-end.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Gensis_Simple_Share_Front_End {
function __construct() {

$icons = get_option( 'genesis_simple_share_sort', array(
'main' => 'genesis_simple_share_google_plus,genesis_simple_share_facebook,genesis_simple_share_twitter,genesis_simple_share_pinterest,genesis_simple_share_linkedin,genesis_simple_share_stumbleupon'
'main' => 'genesis_simple_share_google_plus,genesis_simple_share_facebook,genesis_simple_share_twitter,genesis_simple_share_pinterest,genesis_simple_share_linkedin,genesis_simple_share_stumbleupon,genesis_simple_share_love'
) );

$icons = explode( ',', $icons['main'] );
Expand Down Expand Up @@ -73,6 +73,10 @@ function __construct() {
$icon_sort[] = 'stumbleupon';
break;

case 'genesis_simple_share_love':
$icon_sort[] = 'love';
break;

}
}

Expand Down Expand Up @@ -139,6 +143,13 @@ function load_scripts() {
wp_enqueue_script( 'genesis-simple-share-waypoint-js' );
}

$atts = array(
'nonce' => wp_create_nonce( 'genesis_love' ),
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'love_text' => apply_filters( 'genesis_simple_love_text', __( 'Love', 'genesis' ) )
);
wp_localize_script( 'genesis-simple-share-plugin-js', 'simple_love', $atts );

}

/**
Expand Down Expand Up @@ -419,6 +430,11 @@ function get_icon_output( $location, $icons = array(), $force_show = false ){
$data_title = 'Pin';
break;

case 'love' :

$data_title = __( 'Love', 'genesis-simple-share' );
break;

default:

$data_title = 'Share';
Expand Down
120 changes: 60 additions & 60 deletions lib/sharrre/README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
jQuery Sharrre Plugin
===
Make your sharing widget!
Sharrre is a jQuery plugin that allows you to create nice widgets sharing for Facebook, Twitter, Google Plus (with PHP script) and more.
More information on [Sharrre] (http://sharrre.com/#demos)
Usage
===
$('#sharrre').sharrre({
share: {
googlePlus: true,
facebook: true,
twitter: true
},
url: 'http://sharrre.com'
});
Example
===
<div id="demo1" data-title="sharrre" data-url="http://sharrre.com" ></div>
$(document).ready(function(){
$('#demo1').sharrre({
share: {
googlePlus: true,
facebook: true,
twitter: true,
delicious: true
},
buttons: {
googlePlus: {size: 'tall'},
facebook: {layout: 'box_count'},
twitter: {count: 'vertical'},
delicious: {size: 'tall'}
},
hover: function(api, options){
$(api.element).find('.buttons').show();
},
hide: function(api, options){
$(api.element).find('.buttons').hide();
}
});
});
See example on [official website] (http://sharrre.com/#demos)
Dependencies
===
jQuery 1.7
Author
===
- [Julien Hany](http://hany.fr)
- [Twitter (@_JulienH)](http://twitter.com/_JulienH)
- [Google+](http://plus.google.com/111637545317893682325)
jQuery Sharrre Plugin
===

Make your sharing widget!
Sharrre is a jQuery plugin that allows you to create nice widgets sharing for Facebook, Twitter, Google Plus (with PHP script) and more.
More information on [Sharrre] (http://sharrre.com/#demos)

Usage
===

$('#sharrre').sharrre({
share: {
googlePlus: true,
facebook: true,
twitter: true
},
url: 'http://sharrre.com'
});

Example
===

<div id="demo1" data-title="sharrre" data-url="http://sharrre.com" ></div>
$(document).ready(function(){
$('#demo1').sharrre({
share: {
googlePlus: true,
facebook: true,
twitter: true,
delicious: true
},
buttons: {
googlePlus: {size: 'tall'},
facebook: {layout: 'box_count'},
twitter: {count: 'vertical'},
delicious: {size: 'tall'}
},
hover: function(api, options){
$(api.element).find('.buttons').show();
},
hide: function(api, options){
$(api.element).find('.buttons').hide();
}
});
});

See example on [official website] (http://sharrre.com/#demos)


Dependencies
===

jQuery 1.7

Author
===

- [Julien Hany](http://hany.fr)
- [Twitter (@_JulienH)](http://twitter.com/_JulienH)
- [Google+](http://plus.google.com/111637545317893682325)
Loading