This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sharecount.php
executable file
·79 lines (65 loc) · 2.12 KB
/
sharecount.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Plugin Name: ShareCount
* Plugin URI: https://www.heipomedia.de
* Description: A simple plugin for displaying sharing buttons with their share numbers (Facebook, Twitter, Mail)
* Version: 1.0.0
* Author: Marc Heiduk
* Author URI: https://www.heipomedia.de
* License: MIT
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// Define plugin path
define( 'SHARECOUNT_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
/**
* Enqueues Scripts
*/
function ajax_sharecount_enqueue_scripts()
{
// Enqueue scripts only if we are on a single page
if (is_single()) {
// Enqueue style and script
wp_enqueue_style('sharecount', plugins_url('/css/sharecount.css', __FILE__));
wp_enqueue_script('sharecount', plugins_url('/js/sharecount.js', __FILE__), array(), '1.0', true);
// Localize the scripts and set security nonces against abuse
// Facebook
wp_localize_script('sharecount', 'get_fb_sharecount', array(
'ajax_url' => admin_url('admin-ajax.php'),
'fb_sharecount_nonce' => wp_create_nonce( 'fb_sharecount_nonce' ),
));
// Twitter
wp_localize_script('sharecount', 'get_tw_sharecount', array(
'ajax_url' => admin_url('admin-ajax.php'),
'tw_sharecount_nonce' => wp_create_nonce( 'tw_sharecount_nonce' ),
));
// Mail
wp_localize_script('sharecount', 'get_mail_sharecount', array(
'ajax_url' => admin_url('admin-ajax.php'),
'mail_sharecount_nonce' => wp_create_nonce( 'mail_sharecount_nonce' ),
));
}
}
add_action('wp_enqueue_scripts', 'ajax_sharecount_enqueue_scripts');
/**
* Require Facebook shares
*/
require_once SHARECOUNT_PLUGIN_PATH . 'inc/facebook-shares.php';
/**
* Require Twitter shares
*/
require_once SHARECOUNT_PLUGIN_PATH . 'inc/twitter-shares.php';
/**
* Require Mail shares
*/
require_once SHARECOUNT_PLUGIN_PATH . 'inc/mail-shares.php';
/**
* ShareCount buttons
*/
require_once SHARECOUNT_PLUGIN_PATH . 'inc/display-sharecount.php';
/**
* BBCodes
*/
require_once SHARECOUNT_PLUGIN_PATH . 'inc/bbcodes.php';