Skip to content

Commit

Permalink
Merge pull request #45 from jaredatch/issue/44
Browse files Browse the repository at this point in the history
Issue/44
  • Loading branch information
jaredatch committed May 23, 2016
2 parents a8da394 + 41a6adc commit 8968fdd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Change Log
All notable changes to this project will be documented in this file, formatted via [this recommendation](http://keepachangelog.com/).

## [1.5.9] = 2016-05-23
### Fixed
- Issue with automated theme location placement not working on in all cases. See #44

## [1.5.8] = 2016-05-19
### Fixed
- Issue with 'after_content' theme location not working on some themes. See #43
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# EA Share Count #
**Contributors:** jaredatch, billerickson
**Tags:** facebook, linkedin, pinterest, share, share buttons, social, stumbleupon, twitter
**Requires at least:** 4.1
**Contributors:** jaredatch, billerickson
**Tags:** facebook, linkedin, pinterest, share, share buttons, social, stumbleupon, twitter
**Requires at least:** 4.1
**Tested up to:** 4.5
**Stable tag:** 1.5.8
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
**Stable tag:** 1.5.9
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

EA Share Count is a lean plugin that leverages SharedCount.com API to quickly retrieve, cache, and display various social sharing counts. It's developer-friendly and very extensible.

Expand Down
4 changes: 2 additions & 2 deletions ea-share-count.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin URI: https://github.com/jaredatch/EA-Share-Count
* Description: A lean plugin that leverages SharedCount.com API to quickly retrieve, cache, and display various social sharing counts.
* Author: Bill Erickson & Jared Atchison
* Version: 1.5.8
* Version: 1.5.9
*
* EA Share Count is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -51,7 +51,7 @@ final class EA_Share_Count {
* @since 1.0.0
* @var string
*/
private $version = '1.5.8';
private $version = '1.5.9';

/**
* Core instance
Expand Down
43 changes: 26 additions & 17 deletions includes/class-front.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ class EA_Share_Count_Front {
*/
public $share_link = false;

/**
* Theme location placements.
*
* @since 1.5.9
* @var array
*/
public $locations;

/**
* Primary class constructor.
*
Expand All @@ -32,7 +40,6 @@ public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'header_assets' ), 9 );
add_action( 'wp_footer', array( $this, 'load_assets' ), 1 );
add_action( 'wp_footer', array( $this, 'email_modal' ), 50 );

}

/**
Expand Down Expand Up @@ -95,6 +102,9 @@ function theme_location() {
// Filter theme locations
$locations = apply_filters( 'ea_share_count_theme_locations', $locations );

// Make locations available everywhere
$this->locations = $locations;

// Display share buttons before content
if( $locations['before']['hook'] ) {
add_action( $locations['before']['hook'], array( $this, 'display_before_content' ), $locations['before']['priority'] );
Expand All @@ -108,7 +118,6 @@ function theme_location() {
} elseif( $locations['after']['filter'] ) {
add_filter( $locations['after']['filter'], array( $this, 'display_after_content_filter' ), $locations['after']['priority'] );
}

}

/**
Expand Down Expand Up @@ -259,17 +268,18 @@ public function display( $location = '', $echo = true ) {
*
* @since 1.1.0
*/
public function display_before_content( $echo = true ) {
public function display_before_content() {

$echo = $echo ? true : false;
$options = ea_share()->admin->options();

if ( ( 'before_content' == $options['theme_location'] || 'before_after_content' == $options['theme_location'] ) && !empty( $options['post_type'] ) && is_singular( $options['post_type'] ) ) {
if( $echo ) {
$this->display( 'before_content' );
} else {
return $this->display( 'before_content', false );
}

// Detect if we are using a hook or filter
if ( !empty( $this->locations['before']['hook'] ) ) {
$this->display( 'before_content' );
} elseif ( !empty( $this->locations['before']['filter'] ) ) {
return $this->display( 'before_content', false );
}
}
}

Expand All @@ -283,24 +293,24 @@ public function display_before_content( $echo = true ) {
*/
public function display_before_content_filter( $content ) {

return $this->display_before_content( false ) . $content;

return $this->display_before_content() . $content;
}

/**
* Display After Content
*
* @since 1.1.0
*/
public function display_after_content( $echo = true ) {
public function display_after_content() {

$echo = $echo ? true : false;
$options = ea_share()->admin->options();

if ( ( 'after_content' == $options['theme_location'] || 'before_after_content' == $options['theme_location'] ) && !empty( $options['post_type'] ) && is_singular( $options['post_type'] ) ) {
if( $echo ) {

// Detect if we are using a hook or filter
if ( !empty( $this->locations['after']['hook'] ) ) {
$this->display( 'after_content' );
} else {
} elseif ( !empty( $this->locations['after']['filter'] ) ) {
return $this->display( 'after_content', false );
}
}
Expand All @@ -316,8 +326,7 @@ public function display_after_content( $echo = true ) {
*/
public function display_after_content_filter( $content ) {

return $content . $this->display_after_content( false );

return $content . $this->display_after_content();
}

/**
Expand Down

0 comments on commit 8968fdd

Please sign in to comment.