Coder Social home page Coder Social logo

web5design / shares-counter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gusfune/shares-counter

0.0 3.0 0.0 203 KB

This simple PHP function allows the user to display the total amount of times that an URL have been shared on different social networks.

shares-counter's Introduction

Social Counter (v.1.0.3)

This simple PHP function allows the user to display the amount of times that an URL have been shared on different social networks. Right now it supports Facebook, Twitter, Google Plus and LinkedIn.

This repository contains the open source PHP and is licensed under the Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html).

Usage

First you need to add the function into your PHP code, then you just need to call the function directly into the code:

<?php sharesCounter(); ?>

You can pass some parameters on the function if you don't want to get counts from any specific network or if you want to pass an url that is not the current page.

The parameters are (in order of usage):

  • $url (string): defaults to current url.
  • $echo (bool): if false it will just return the sum as a variable, if true it echoes the results. Defaults to true.
  • $facebook (bool): defaults to true.
  • $twitter (bool): defaults to true.
  • $gplus (bool): defaults to true.
  • $linkedin (bool): defaults to true.

For example, if you want to remove linkedin from the list, you can:

<?php sharesCounter('', true, true, true, true, false); ?>

To use the code in Wordpress for any specific post, you can simply add (within the loop):

<?php sharesCounter( get_permalink() ); ?>

You can also return the result as a variable instead of echoing the number:

<?php $variable = sharesCounter('', false); ?>

For OOP version of this code, please refer to the branch linked below: https://github.com/gusfune/shares-counter/tree/oop

If you are using Wordpress, you should use the WPShare-Counter that was created based on this code.: https://github.com/phalkmin/WPShare-Counter

Contributing

When commiting, keep all lines to less than 80 characters, and try to follow the existing style.

Before creating a pull request, squash your commits into a single commit.

Add the comments where needed, and provide ample explanation in the commit message.

shares-counter's People

Contributors

fjorgemota avatar

Watchers

JT5D avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.