Version Description
- Added action and filter hooks for extensibility.
- Fixed a bug with upgrade code being called multiple times.
- Removed PressTrends integration.
- Tested up to WordPress 3.9.
Download this release
Release Info
Developer | pderksen |
Plugin | Pinterest "Pin It" Button |
Version | 2.0.3 |
Comparing to | |
See all releases |
Code changes from version 2.0.2 to 2.0.3
- assets/index.php +1 -1
- class-pinterest-pin-it-button.php +34 -53
- css/admin.css +2 -4
- css/index.php +1 -1
- css/public.css +1 -6
- fonts/index.php +1 -1
- includes/admin-notices.php +16 -13
- includes/hooks-examples.php +107 -0
- includes/index.php +1 -1
- includes/misc-functions.php +12 -1
- includes/presstrends.php +0 -64
- includes/register-settings.php +36 -16
- includes/shortcodes.php +16 -3
- includes/upgrade-plugin.php +11 -1
- includes/widgets.php +36 -6
- index.php +1 -1
- pinterest-pin-it-button.php +5 -2
- readme.txt +30 -5
- screenshot-3.png +0 -0
- screenshot-4.png +0 -0
- screenshot-5.png +0 -0
- screenshot-6.png +0 -0
- screenshot-7.png +0 -0
- views/admin-help.php +10 -2
- views/admin-sidebar.php +0 -3
- views/admin.php +2 -2
- views/index.php +1 -1
- views/post-meta-display.php +4 -4
- views/public.php +61 -24
assets/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
class-pinterest-pin-it-button.php
CHANGED
@@ -27,7 +27,7 @@ class Pinterest_Pin_It_Button {
|
|
27 |
* and README.txt changelog
|
28 |
**************************************/
|
29 |
|
30 |
-
protected $version = '2.0.
|
31 |
|
32 |
/**
|
33 |
* Unique identifier for your plugin.
|
@@ -64,23 +64,22 @@ class Pinterest_Pin_It_Button {
|
|
64 |
*
|
65 |
* @since 2.0.0
|
66 |
*/
|
67 |
-
|
68 |
/**
|
69 |
-
*
|
70 |
-
*
|
71 |
-
* @since 2.0.0
|
72 |
*
|
73 |
-
* @
|
|
|
74 |
*/
|
75 |
-
protected $presstrends_auth = '0ebdi3uscgaztp99nnbam6rl6i2186qwo';
|
76 |
-
|
77 |
private function __construct() {
|
78 |
// Setup constants.
|
79 |
$this->setup_constants();
|
80 |
|
81 |
// Run our upgrade checks first and update our version option.
|
82 |
-
|
83 |
-
|
|
|
|
|
84 |
|
85 |
// Include required files.
|
86 |
add_action( 'init', array( $this, 'includes' ), 1 );
|
@@ -104,9 +103,25 @@ class Pinterest_Pin_It_Button {
|
|
104 |
|
105 |
// Add plugin listing "Settings" action link.
|
106 |
add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . $this->plugin_slug . '.php' ), array( $this, 'settings_link' ) );
|
107 |
-
|
108 |
-
//
|
109 |
-
add_action( 'admin_init', array( $this, '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
/**
|
@@ -251,37 +266,13 @@ class Pinterest_Pin_It_Button {
|
|
251 |
public function enqueue_scripts() {
|
252 |
global $pib_options;
|
253 |
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
// Enqueue Pinterest JS plugin boilerplate style. Don't tack on plugin version.
|
261 |
-
wp_enqueue_script( $this->plugin_slug . '-pinterest-pinit', '//assets.pinterest.com/js/pinit.js', array(), null, true );
|
262 |
-
}
|
263 |
-
//}
|
264 |
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* Use async version of pinit.js
|
268 |
-
*
|
269 |
-
* @since
|
270 |
-
*/
|
271 |
-
|
272 |
-
/*public function use_async_pinit() {
|
273 |
-
$script = "<script type='text/javascript'>\n";
|
274 |
-
$script .= "(function(d){\n";
|
275 |
-
$script .= "var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');\n";
|
276 |
-
$script .= "p.type = 'text/javascript';\n";
|
277 |
-
$script .= "p.async = true;\n";
|
278 |
-
$script .= "p.src = '//assets.pinterest.com/js/pinit.js';\n";
|
279 |
-
$script .= "f.parentNode.insertBefore(p, f);\n";
|
280 |
-
$script .= "}(document));\n";
|
281 |
-
$script .= "</script>\n";
|
282 |
-
|
283 |
-
echo $script;
|
284 |
-
}*/
|
285 |
|
286 |
/**
|
287 |
* Register the administration menu for this plugin into the WordPress Dashboard menu.
|
@@ -443,14 +434,4 @@ class Pinterest_Pin_It_Button {
|
|
443 |
if( get_current_screen()->id == 'plugins' )
|
444 |
include_once( 'views/admin-install-notice.php' );
|
445 |
}
|
446 |
-
|
447 |
-
public function use_presstrends_tracking() {
|
448 |
-
global $pib_options;
|
449 |
-
|
450 |
-
// Include tracking if option checked.
|
451 |
-
if( ! empty( $pib_options['presstrends_tracking'] ) && ( 1 == $pib_options['presstrends_tracking'] ) ) {
|
452 |
-
include( 'includes/presstrends.php' );
|
453 |
-
pib_run_presstrends_tracking( $this->presstrends_auth );
|
454 |
-
}
|
455 |
-
}
|
456 |
}
|
27 |
* and README.txt changelog
|
28 |
**************************************/
|
29 |
|
30 |
+
protected $version = '2.0.3';
|
31 |
|
32 |
/**
|
33 |
* Unique identifier for your plugin.
|
64 |
*
|
65 |
* @since 2.0.0
|
66 |
*/
|
67 |
+
|
68 |
/**
|
69 |
+
* Initialize main plugin functions and add appropriate hooks/filter calls
|
|
|
|
|
70 |
*
|
71 |
+
* @since 2.0.0
|
72 |
+
*
|
73 |
*/
|
|
|
|
|
74 |
private function __construct() {
|
75 |
// Setup constants.
|
76 |
$this->setup_constants();
|
77 |
|
78 |
// Run our upgrade checks first and update our version option.
|
79 |
+
if( ! get_option( 'pib_upgrade_has_run' ) ) {
|
80 |
+
add_action( 'init', array( $this, 'upgrade_plugin' ), 0 );
|
81 |
+
update_option( 'pib_version', $this->version );
|
82 |
+
}
|
83 |
|
84 |
// Include required files.
|
85 |
add_action( 'init', array( $this, 'includes' ), 1 );
|
103 |
|
104 |
// Add plugin listing "Settings" action link.
|
105 |
add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . $this->plugin_slug . '.php' ), array( $this, 'settings_link' ) );
|
106 |
+
|
107 |
+
// Check WP version
|
108 |
+
add_action( 'admin_init', array( $this, 'check_wp_version' ) );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Make sure user has the minimum required version of WordPress installed to use the plugin
|
113 |
+
*
|
114 |
+
* @since 1.0.0
|
115 |
+
*/
|
116 |
+
public function check_wp_version() {
|
117 |
+
global $wp_version;
|
118 |
+
$required_wp_version = '3.5.2';
|
119 |
+
|
120 |
+
if ( version_compare( $wp_version, $required_wp_version, '<' ) ) {
|
121 |
+
deactivate_plugins( PIB_MAIN_FILE );
|
122 |
+
wp_die( sprintf( __( $this->get_plugin_title() . ' requires WordPress version <strong>' . $required_wp_version . '</strong> to run properly. ' .
|
123 |
+
'Please update WordPress before reactivating this plugin. <a href="%s">Return to Plugins</a>.', 'pib' ), get_admin_url( '', 'plugins.php' ) ) );
|
124 |
+
}
|
125 |
}
|
126 |
|
127 |
/**
|
266 |
public function enqueue_scripts() {
|
267 |
global $pib_options;
|
268 |
|
269 |
+
// If this option is empty then it means we can load the pinit.js, otherwise do not load it
|
270 |
+
if( empty( $pib_options['no_pinit_js'] ) ) {
|
271 |
+
// Enqueue Pinterest JS plugin boilerplate style. Don't tack on plugin version.
|
272 |
+
// We DO NOT include the plugin slug here. This is so that this can be uniform across all of our plugins
|
273 |
+
wp_enqueue_script( 'pinterest-pinit-js', '//assets.pinterest.com/js/pinit.js', array(), null, true );
|
274 |
+
}
|
|
|
|
|
|
|
|
|
275 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
|
277 |
/**
|
278 |
* Register the administration menu for this plugin into the WordPress Dashboard menu.
|
434 |
if( get_current_screen()->id == 'plugins' )
|
435 |
include_once( 'views/admin-install-notice.php' );
|
436 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
}
|
css/admin.css
CHANGED
@@ -4,17 +4,15 @@
|
|
4 |
background: transparent url('../assets/pinterest-icon-32.png') no-repeat;
|
5 |
}
|
6 |
|
7 |
-
/* This icon is taken from the Flat Social Media Icons
|
8 |
* http://designmodo.com/flat-social-icons/
|
9 |
*/
|
10 |
-
|
11 |
a.pib-external-link {
|
12 |
background: transparent url('../assets/icon-external-link.gif') center right no-repeat;
|
13 |
padding-right: 17px;
|
14 |
}
|
15 |
|
16 |
/* Layout the page similar to the built-in post edit screen. */
|
17 |
-
|
18 |
#pib-settings {
|
19 |
margin-right: 310px;
|
20 |
}
|
@@ -36,7 +34,6 @@ a.pib-external-link {
|
|
36 |
}
|
37 |
|
38 |
/* Sidebar container. Taken from Flat UI .tile & popover classes. */
|
39 |
-
|
40 |
#pib-settings-sidebar .sidebar-container {
|
41 |
background-color: #fff;
|
42 |
border: 1px solid #ccc;
|
@@ -98,6 +95,7 @@ a.pib-external-link {
|
|
98 |
}
|
99 |
|
100 |
#pib-settings-sidebar .sidebar-content p {
|
|
|
101 |
line-height: 1.4em;
|
102 |
margin: 0 0 10px;
|
103 |
}
|
4 |
background: transparent url('../assets/pinterest-icon-32.png') no-repeat;
|
5 |
}
|
6 |
|
7 |
+
/* This icon is taken from the Flat Social Media Icons from Designmodo at
|
8 |
* http://designmodo.com/flat-social-icons/
|
9 |
*/
|
|
|
10 |
a.pib-external-link {
|
11 |
background: transparent url('../assets/icon-external-link.gif') center right no-repeat;
|
12 |
padding-right: 17px;
|
13 |
}
|
14 |
|
15 |
/* Layout the page similar to the built-in post edit screen. */
|
|
|
16 |
#pib-settings {
|
17 |
margin-right: 310px;
|
18 |
}
|
34 |
}
|
35 |
|
36 |
/* Sidebar container. Taken from Flat UI .tile & popover classes. */
|
|
|
37 |
#pib-settings-sidebar .sidebar-container {
|
38 |
background-color: #fff;
|
39 |
border: 1px solid #ccc;
|
95 |
}
|
96 |
|
97 |
#pib-settings-sidebar .sidebar-content p {
|
98 |
+
font-size: 14px;
|
99 |
line-height: 1.4em;
|
100 |
margin: 0 0 10px;
|
101 |
}
|
css/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
css/public.css
CHANGED
@@ -2,11 +2,7 @@
|
|
2 |
|
3 |
/* Pinterest "Pin It" Button Public CSS */
|
4 |
|
5 |
-
|
6 |
-
*
|
7 |
-
* DIV surrounding button
|
8 |
-
*
|
9 |
-
***/
|
10 |
div.pin-it-btn-wrapper,
|
11 |
div.pin-it-btn-wrapper-shortcode,
|
12 |
div.pin-it-btn-wrapper-widget {
|
@@ -49,7 +45,6 @@ div.pin-it-btn-wrapper-widget a:hover {
|
|
49 |
}
|
50 |
|
51 |
/* Align left/right/center options */
|
52 |
-
|
53 |
.pib-align-left {
|
54 |
text-align: left;
|
55 |
}
|
2 |
|
3 |
/* Pinterest "Pin It" Button Public CSS */
|
4 |
|
5 |
+
/* Styles for the Pin It Button wrapper DIV */
|
|
|
|
|
|
|
|
|
6 |
div.pin-it-btn-wrapper,
|
7 |
div.pin-it-btn-wrapper-shortcode,
|
8 |
div.pin-it-btn-wrapper-widget {
|
45 |
}
|
46 |
|
47 |
/* Align left/right/center options */
|
|
|
48 |
.pib-align-left {
|
49 |
text-align: left;
|
50 |
}
|
fonts/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
includes/admin-notices.php
CHANGED
@@ -12,30 +12,33 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
function pib_register_admin_notices() {
|
16 |
-
// The first check will show message if general tab is updated. The additional check is if the plugin page is first clicked on and the 'tab' has not been set yet.
|
17 |
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
if ( ( isset( $_GET['tab'] ) && 'general' == $_GET['tab'] ) && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] )
|
21 |
|| ( !isset( $_GET['tab'] ) && $is_pib_settings_page !== false && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) ) ) {
|
22 |
-
add_settings_error( 'pib-notices', 'pib-general-updated', __( 'General settings updated.', 'pib' ), 'updated' );
|
23 |
-
}
|
24 |
-
|
25 |
-
if ( ( isset( $_GET['tab'] ) && 'post_visibility' == $_GET['tab'] ) && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) ) {
|
26 |
-
add_settings_error( 'pib-notices', 'pib-post_visibility-updated', __( 'Post Visibility settings updated.', 'pib' ), 'updated' );
|
27 |
}
|
28 |
|
29 |
-
if ( ( isset( $_GET['tab'] ) && '
|
30 |
-
add_settings_error( 'pib-notices', 'pib-
|
31 |
}
|
32 |
|
33 |
-
if ( ( isset( $_GET['tab'] ) && '
|
34 |
-
add_settings_error( 'pib-notices', 'pib-
|
35 |
}
|
36 |
|
37 |
-
if ( ( isset( $_GET['tab'] ) && 'advanced' == $_GET['tab'] ) && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) ) {
|
38 |
-
add_settings_error( 'pib-notices', 'pib-advanced-updated', __( 'Advanced settings updated.', 'pib' ), 'updated' );
|
39 |
}
|
40 |
|
41 |
settings_errors( 'pib-notices' );
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
/**
|
16 |
+
* Register admin notices that are used when plugin settings are saved
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
*/
|
20 |
function pib_register_admin_notices() {
|
|
|
21 |
|
22 |
+
global $pib_vars;
|
23 |
+
|
24 |
+
// The first check will show message if general tab is updated. The additional check is if the plugin page is first clicked on and the 'tab' has not been set yet.
|
25 |
+
$is_pib_settings_page = strpos( ( isset( $_GET['page'] ) ? $_GET['page'] : '' ), 'pinterest-pin-it-button' );
|
26 |
|
27 |
if ( ( isset( $_GET['tab'] ) && 'general' == $_GET['tab'] ) && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] )
|
28 |
|| ( !isset( $_GET['tab'] ) && $is_pib_settings_page !== false && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) ) ) {
|
29 |
+
add_settings_error( 'pib-notices', 'pib-general-updated', __( 'General settings updated. ' . $pib_vars['cache_message'], 'pib' ), 'updated' );
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
+
if ( ( $is_pib_settings_page !== false ) && ( isset( $_GET['tab'] ) && 'post_visibility' == $_GET['tab'] ) && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) ) {
|
33 |
+
add_settings_error( 'pib-notices', 'pib-post_visibility-updated', __( 'Post Visibility settings updated. ' . $pib_vars['cache_message'], 'pib' ), 'updated' );
|
34 |
}
|
35 |
|
36 |
+
if ( ( $is_pib_settings_page !== false ) && ( isset( $_GET['tab'] ) && 'styles' == $_GET['tab'] ) && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) ) {
|
37 |
+
add_settings_error( 'pib-notices', 'pib-styles-updated', __( 'Styles settings updated. ' . $pib_vars['cache_message'], 'pib' ), 'updated' );
|
38 |
}
|
39 |
|
40 |
+
if ( ( $is_pib_settings_page !== false ) && ( isset( $_GET['tab'] ) && 'advanced' == $_GET['tab'] ) && ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) ) {
|
41 |
+
add_settings_error( 'pib-notices', 'pib-advanced-updated', __( 'Advanced settings updated. ' . $pib_vars['cache_message'], 'pib' ), 'updated' );
|
42 |
}
|
43 |
|
44 |
settings_errors( 'pib-notices' );
|
includes/hooks-examples.php
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*************************
|
4 |
+
* FILTER HOOKS
|
5 |
+
************************/
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Modifies the HTML output of the shortcode button
|
9 |
+
*
|
10 |
+
* @since 2.0.3
|
11 |
+
*/
|
12 |
+
function test_pib_shortcode_html( $html ) {
|
13 |
+
return '<div style="border: 5px solid #f00; padding: 15px;">' . $html . '</div>';
|
14 |
+
}
|
15 |
+
//add_filter( 'pib_shortcode_html', 'test_pib_shortcode_html' );
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Used to modify the widget HTML
|
20 |
+
*
|
21 |
+
* @since 2.0.3
|
22 |
+
*/
|
23 |
+
function test_pib_widget_html( $html ) {
|
24 |
+
return '<div style="border: 5px solid #f00; padding: 15px;">' . $html . '</div>';
|
25 |
+
}
|
26 |
+
//add_filter( 'pib_widget_html', 'test_pib_widget_html' );
|
27 |
+
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Used to modify the regular button HTML
|
31 |
+
*
|
32 |
+
* @since 2.0.3
|
33 |
+
*/
|
34 |
+
function test_pib_button_html( $html ) {
|
35 |
+
return '<div style="border: 5px solid #f00; padding: 15px;">' . $html . '</div>';
|
36 |
+
}
|
37 |
+
//add_filter( 'pib_button_html', 'test_pib_button_html' );
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Outputs additional HTML before the PIB shortcode
|
42 |
+
*
|
43 |
+
* @since 2.0.3
|
44 |
+
*/
|
45 |
+
function test_pib_shortcode_before( $before_html ) {
|
46 |
+
return $before_html . '<p>Before</p>';
|
47 |
+
}
|
48 |
+
//add_filter( 'pib_shortcode_before', 'test_pib_shortcode_before' );
|
49 |
+
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Outputs additional HTML after the PIB shortcode
|
53 |
+
*
|
54 |
+
* @since 2.0.3
|
55 |
+
*/
|
56 |
+
function test_pib_shortcode_after() {
|
57 |
+
return $after_html . '<p>After</p>';
|
58 |
+
}
|
59 |
+
//add_filter( 'pib_shortcode_after', 'test_pib_shortcode_after' );
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Outputs additional HTML before the default button
|
64 |
+
*
|
65 |
+
* @since 2.0.3
|
66 |
+
*/
|
67 |
+
function test_pib_button_before( $before_html ) {
|
68 |
+
return '<p>Button Before</p>';
|
69 |
+
}
|
70 |
+
add_filter( 'pib_button_before', 'test_pib_button_before' );
|
71 |
+
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Outputs additional HTML after the default button
|
75 |
+
*
|
76 |
+
* @since 2.0.3
|
77 |
+
*/
|
78 |
+
function test_pib_button_after( $after_html ) {
|
79 |
+
return '<p>Button After</p>';
|
80 |
+
}
|
81 |
+
add_filter( 'pib_button_after', 'test_pib_button_after' );
|
82 |
+
|
83 |
+
|
84 |
+
/*************************
|
85 |
+
* ACTION HOOKS
|
86 |
+
************************/
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Outputs additional HTML after the default button
|
90 |
+
*
|
91 |
+
* @since 2.0.3
|
92 |
+
*/
|
93 |
+
function test_pib_widget_before() {
|
94 |
+
echo '<p>Widget Before</p>';
|
95 |
+
}
|
96 |
+
add_action( 'pib_widget_before', 'test_pib_widget_before' );
|
97 |
+
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Outputs additional HTML after the default button
|
101 |
+
*
|
102 |
+
* @since 2.0.3
|
103 |
+
*/
|
104 |
+
function test_pib_widget_after() {
|
105 |
+
echo '<p>Widget After</p>';
|
106 |
+
}
|
107 |
+
add_action( 'pib_widget_after', 'test_pib_widget_after' );
|
includes/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
includes/misc-functions.php
CHANGED
@@ -12,6 +12,18 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
/**
|
16 |
* Google Analytics campaign URL.
|
17 |
*
|
@@ -42,7 +54,6 @@ function pib_ga_campaign_url( $base_url, $source, $medium, $campaign ) {
|
|
42 |
*
|
43 |
* @since 2.0.0
|
44 |
*/
|
45 |
-
|
46 |
function pib_rss_news() {
|
47 |
// Get RSS Feed(s).
|
48 |
include_once( ABSPATH . WPINC . '/feed.php' );
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
|
16 |
+
/*
|
17 |
+
* Reusable variables
|
18 |
+
*
|
19 |
+
* @since 2.0.3
|
20 |
+
*/
|
21 |
+
global $pib_vars;
|
22 |
+
|
23 |
+
$pib_vars['cache_message'] = 'If you have caching enabled please empty it before viewing your changes.';
|
24 |
+
$pib_vars['post_meta_message'] = '';
|
25 |
+
|
26 |
+
|
27 |
/**
|
28 |
* Google Analytics campaign URL.
|
29 |
*
|
54 |
*
|
55 |
* @since 2.0.0
|
56 |
*/
|
|
|
57 |
function pib_rss_news() {
|
58 |
// Get RSS Feed(s).
|
59 |
include_once( ABSPATH . WPINC . '/feed.php' );
|
includes/presstrends.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Presstrends tracking function.
|
5 |
-
*
|
6 |
-
* @package PIB
|
7 |
-
* @subpackage Includes
|
8 |
-
* @author Phil Derksen <pderksen@gmail.com>, Nick Young <mycorpweb@gmail.com>
|
9 |
-
*/
|
10 |
-
|
11 |
-
// Exit if accessed directly.
|
12 |
-
if ( ! defined( 'ABSPATH' ) )
|
13 |
-
exit;
|
14 |
-
|
15 |
-
function pib_run_presstrends_tracking( $auth ) {
|
16 |
-
// PressTrends Account API Key
|
17 |
-
$api_key = 'qsu6mq75d69xqhpadhdz09rfqze9c6u499q6';
|
18 |
-
|
19 |
-
// Start of Metrics
|
20 |
-
global $wpdb;
|
21 |
-
$data = get_transient( 'presstrends_cache_data' );
|
22 |
-
if ( !$data || $data == '' ) {
|
23 |
-
$api_base = 'http://api.presstrends.io/index.php/api/pluginsites/update/auth/';
|
24 |
-
$url = $api_base . $auth . '/api/' . $api_key . '/';
|
25 |
-
$count_posts = wp_count_posts();
|
26 |
-
$count_pages = wp_count_posts( 'page' );
|
27 |
-
$comments_count = wp_count_comments();
|
28 |
-
if ( function_exists( 'wp_get_theme' ) ) {
|
29 |
-
$theme_data = wp_get_theme();
|
30 |
-
$theme_name = urlencode( $theme_data->Name );
|
31 |
-
} else {
|
32 |
-
$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
|
33 |
-
$theme_name = $theme_data['Name'];
|
34 |
-
}
|
35 |
-
$plugin_name = '&';
|
36 |
-
foreach ( get_plugins() as $plugin_info ) {
|
37 |
-
$plugin_name .= $plugin_info['Name'] . '&';
|
38 |
-
}
|
39 |
-
// CHANGE __FILE__ PATH IF LOCATED OUTSIDE MAIN PLUGIN FILE
|
40 |
-
$plugin_data = get_plugin_data( __FILE__ );
|
41 |
-
$posts_with_comments = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type='post' AND comment_count > 0" );
|
42 |
-
$data = array(
|
43 |
-
'url' => base64_encode(site_url()),
|
44 |
-
'posts' => $count_posts->publish,
|
45 |
-
'pages' => $count_pages->publish,
|
46 |
-
'comments' => $comments_count->total_comments,
|
47 |
-
'approved' => $comments_count->approved,
|
48 |
-
'spam' => $comments_count->spam,
|
49 |
-
'pingbacks' => $wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_type = 'pingback'" ),
|
50 |
-
'post_conversion' => ( $count_posts->publish > 0 && $posts_with_comments > 0 ) ? number_format( ( $posts_with_comments / $count_posts->publish ) * 100, 0, '.', '' ) : 0,
|
51 |
-
'theme_version' => $plugin_data['Version'],
|
52 |
-
'theme_name' => $theme_name,
|
53 |
-
'site_name' => str_replace( ' ', '', get_bloginfo( 'name' ) ),
|
54 |
-
'plugins' => count( get_option( 'active_plugins' ) ),
|
55 |
-
'plugin' => urlencode( $plugin_name ),
|
56 |
-
'wpversion' => get_bloginfo( 'version' ),
|
57 |
-
);
|
58 |
-
foreach ( $data as $k => $v ) {
|
59 |
-
$url .= $k . '/' . $v . '/';
|
60 |
-
}
|
61 |
-
wp_remote_get( $url );
|
62 |
-
set_transient( 'presstrends_cache_data', $data, 60 * 60 * 24 );
|
63 |
-
}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
includes/register-settings.php
CHANGED
@@ -12,6 +12,11 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
function pib_register_settings() {
|
16 |
$pib_settings = array(
|
17 |
|
@@ -81,13 +86,6 @@ function pib_register_settings() {
|
|
81 |
'name' => __( 'Save Settings', 'pib' ),
|
82 |
'desc' => __( 'Save your settings when uninstalling this plugin. Useful when upgrading or re-installing.', 'pib' ),
|
83 |
'type' => 'checkbox'
|
84 |
-
),
|
85 |
-
'presstrends_tracking' => array(
|
86 |
-
'id' => 'presstrends_tracking',
|
87 |
-
'name' => __( 'Allow Anonymous Usage Tracking', 'pib' ),
|
88 |
-
'desc' => __( 'If checked, this option will enable PressTrends, which is a simple usage tracker that allows us to see how our customers are using our plugins.', 'pib' ) . '<br/>' .
|
89 |
-
__( 'This anonymous data gives us insight on how we can improve our plugins for you. It will not track any user details, so your security and privacy are safe with us.', 'pib' ),
|
90 |
-
'type' => 'checkbox'
|
91 |
)
|
92 |
),
|
93 |
|
@@ -152,13 +150,7 @@ function pib_register_settings() {
|
|
152 |
'<p class="description">' . __( 'Check this option if you have <code>pinit.js</code> referenced in another plugin, widget or your theme. ' .
|
153 |
'Ouputting <code>pinit.js</code> more than once on a page can cause conflicts.', 'pib' ) . '</p>',
|
154 |
'type' => 'checkbox'
|
155 |
-
)
|
156 |
-
- 'use_async' => array(
|
157 |
-
- 'id' => 'use_async',
|
158 |
-
- 'name' => __( 'Load <code>pinit.js</code> asynchronously', 'pib' ),
|
159 |
-
- 'desc' => __( 'This may improve page load time by loading <code>pinit.js</code> independent of the rest of the page.', 'pib' ) . '</p>',
|
160 |
-
- 'type' => 'checkbox'
|
161 |
-
)*/
|
162 |
)
|
163 |
);
|
164 |
|
@@ -273,7 +265,6 @@ add_action( 'admin_init', 'pib_register_settings' );
|
|
273 |
* @param string $section Section of settings apge.
|
274 |
* @return array $args parameter to use with add_settings_field call.
|
275 |
*/
|
276 |
-
|
277 |
function pib_get_settings_field_args( $option, $section ) {
|
278 |
$settings_args = array(
|
279 |
'id' => $option['id'],
|
@@ -296,6 +287,9 @@ function pib_get_settings_field_args( $option, $section ) {
|
|
296 |
|
297 |
/*
|
298 |
* Radio button callback function
|
|
|
|
|
|
|
299 |
*/
|
300 |
function pib_radio_callback( $args ) {
|
301 |
global $pib_options;
|
@@ -330,6 +324,9 @@ function pib_radio_callback( $args ) {
|
|
330 |
|
331 |
/*
|
332 |
* Single checkbox callback function
|
|
|
|
|
|
|
333 |
*/
|
334 |
function pib_checkbox_callback( $args ) {
|
335 |
global $pib_options;
|
@@ -346,8 +343,10 @@ function pib_checkbox_callback( $args ) {
|
|
346 |
|
347 |
/*
|
348 |
* Multiple checkboxes callback function
|
|
|
|
|
|
|
349 |
*/
|
350 |
-
|
351 |
function pib_multicheck_callback( $args ) {
|
352 |
global $pib_options;
|
353 |
|
@@ -375,6 +374,9 @@ function pib_multicheck_callback( $args ) {
|
|
375 |
|
376 |
/*
|
377 |
* Select box callback function
|
|
|
|
|
|
|
378 |
*/
|
379 |
function pib_select_callback( $args ) {
|
380 |
global $pib_options;
|
@@ -403,6 +405,9 @@ function pib_select_callback( $args ) {
|
|
403 |
|
404 |
/*
|
405 |
* Textarea callback function
|
|
|
|
|
|
|
406 |
*/
|
407 |
function pib_textarea_callback( $args ) {
|
408 |
global $pib_options;
|
@@ -424,6 +429,9 @@ function pib_textarea_callback( $args ) {
|
|
424 |
|
425 |
/**
|
426 |
* Number callback function
|
|
|
|
|
|
|
427 |
*/
|
428 |
function pib_number_callback( $args ) {
|
429 |
global $pib_options;
|
@@ -447,6 +455,9 @@ function pib_number_callback( $args ) {
|
|
447 |
* Textbox callback function
|
448 |
* Valid built-in size CSS class values:
|
449 |
* small-text, regular-text, large-text
|
|
|
|
|
|
|
450 |
*/
|
451 |
function pib_text_callback( $args ) {
|
452 |
global $pib_options;
|
@@ -468,6 +479,9 @@ function pib_text_callback( $args ) {
|
|
468 |
|
469 |
/*
|
470 |
* Function we can use to sanitize the input data and return it when saving options
|
|
|
|
|
|
|
471 |
*/
|
472 |
function pib_settings_sanitize( $input ) {
|
473 |
add_settings_error( 'pib-notices', '', '', '' );
|
@@ -476,6 +490,9 @@ function pib_settings_sanitize( $input ) {
|
|
476 |
|
477 |
/*
|
478 |
* Default callback function if correct one does not exist
|
|
|
|
|
|
|
479 |
*/
|
480 |
function pib_missing_callback( $args ) {
|
481 |
printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 'pib' ), $args['id'] );
|
@@ -483,6 +500,9 @@ function pib_missing_callback( $args ) {
|
|
483 |
|
484 |
/*
|
485 |
* Function used to return an array of all of the plugin settings
|
|
|
|
|
|
|
486 |
*/
|
487 |
function pib_get_settings() {
|
488 |
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
/**
|
16 |
+
* Main function to register all of the plugin settings
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
*/
|
20 |
function pib_register_settings() {
|
21 |
$pib_settings = array(
|
22 |
|
86 |
'name' => __( 'Save Settings', 'pib' ),
|
87 |
'desc' => __( 'Save your settings when uninstalling this plugin. Useful when upgrading or re-installing.', 'pib' ),
|
88 |
'type' => 'checkbox'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
)
|
90 |
),
|
91 |
|
150 |
'<p class="description">' . __( 'Check this option if you have <code>pinit.js</code> referenced in another plugin, widget or your theme. ' .
|
151 |
'Ouputting <code>pinit.js</code> more than once on a page can cause conflicts.', 'pib' ) . '</p>',
|
152 |
'type' => 'checkbox'
|
153 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
)
|
155 |
);
|
156 |
|
265 |
* @param string $section Section of settings apge.
|
266 |
* @return array $args parameter to use with add_settings_field call.
|
267 |
*/
|
|
|
268 |
function pib_get_settings_field_args( $option, $section ) {
|
269 |
$settings_args = array(
|
270 |
'id' => $option['id'],
|
287 |
|
288 |
/*
|
289 |
* Radio button callback function
|
290 |
+
*
|
291 |
+
* @since 2.0.0
|
292 |
+
*
|
293 |
*/
|
294 |
function pib_radio_callback( $args ) {
|
295 |
global $pib_options;
|
324 |
|
325 |
/*
|
326 |
* Single checkbox callback function
|
327 |
+
*
|
328 |
+
* @since 2.0.0
|
329 |
+
*
|
330 |
*/
|
331 |
function pib_checkbox_callback( $args ) {
|
332 |
global $pib_options;
|
343 |
|
344 |
/*
|
345 |
* Multiple checkboxes callback function
|
346 |
+
*
|
347 |
+
* @since 2.0.0
|
348 |
+
*
|
349 |
*/
|
|
|
350 |
function pib_multicheck_callback( $args ) {
|
351 |
global $pib_options;
|
352 |
|
374 |
|
375 |
/*
|
376 |
* Select box callback function
|
377 |
+
*
|
378 |
+
* @since 2.0.0
|
379 |
+
*
|
380 |
*/
|
381 |
function pib_select_callback( $args ) {
|
382 |
global $pib_options;
|
405 |
|
406 |
/*
|
407 |
* Textarea callback function
|
408 |
+
*
|
409 |
+
* @since 2.0.0
|
410 |
+
*
|
411 |
*/
|
412 |
function pib_textarea_callback( $args ) {
|
413 |
global $pib_options;
|
429 |
|
430 |
/**
|
431 |
* Number callback function
|
432 |
+
*
|
433 |
+
* @since 2.0.0
|
434 |
+
*
|
435 |
*/
|
436 |
function pib_number_callback( $args ) {
|
437 |
global $pib_options;
|
455 |
* Textbox callback function
|
456 |
* Valid built-in size CSS class values:
|
457 |
* small-text, regular-text, large-text
|
458 |
+
*
|
459 |
+
* @since 2.0.0
|
460 |
+
*
|
461 |
*/
|
462 |
function pib_text_callback( $args ) {
|
463 |
global $pib_options;
|
479 |
|
480 |
/*
|
481 |
* Function we can use to sanitize the input data and return it when saving options
|
482 |
+
*
|
483 |
+
* @since 2.0.0
|
484 |
+
*
|
485 |
*/
|
486 |
function pib_settings_sanitize( $input ) {
|
487 |
add_settings_error( 'pib-notices', '', '', '' );
|
490 |
|
491 |
/*
|
492 |
* Default callback function if correct one does not exist
|
493 |
+
*
|
494 |
+
* @since 2.0.0
|
495 |
+
*
|
496 |
*/
|
497 |
function pib_missing_callback( $args ) {
|
498 |
printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 'pib' ), $args['id'] );
|
500 |
|
501 |
/*
|
502 |
* Function used to return an array of all of the plugin settings
|
503 |
+
*
|
504 |
+
* @since 2.0.0
|
505 |
+
*
|
506 |
*/
|
507 |
function pib_get_settings() {
|
508 |
|
includes/shortcodes.php
CHANGED
@@ -12,6 +12,11 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
function pib_pinit_shortcode( $attr ) {
|
16 |
global $pib_options;
|
17 |
global $post;
|
@@ -76,7 +81,7 @@ function pib_pinit_shortcode( $attr ) {
|
|
76 |
|
77 |
//Don't wrap with div or set float class if "remove div" is checked
|
78 |
if ( $remove_div ) {
|
79 |
-
|
80 |
}
|
81 |
else {
|
82 |
//Surround with div tag
|
@@ -92,8 +97,16 @@ function pib_pinit_shortcode( $attr ) {
|
|
92 |
$align_class = 'pib-align-center';
|
93 |
}
|
94 |
|
95 |
-
|
96 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
-
|
99 |
add_shortcode( 'pinit', 'pib_pinit_shortcode' );
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
/**
|
16 |
+
* Function to process [pinit] shortcodes
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
*/
|
20 |
function pib_pinit_shortcode( $attr ) {
|
21 |
global $pib_options;
|
22 |
global $post;
|
81 |
|
82 |
//Don't wrap with div or set float class if "remove div" is checked
|
83 |
if ( $remove_div ) {
|
84 |
+
$html = $base_btn;
|
85 |
}
|
86 |
else {
|
87 |
//Surround with div tag
|
97 |
$align_class = 'pib-align-center';
|
98 |
}
|
99 |
|
100 |
+
$html = '<div class="pin-it-btn-wrapper-shortcode ' . $align_class . '">' . $base_btn . '</div>';
|
101 |
}
|
102 |
+
|
103 |
+
$before_html = '';
|
104 |
+
$after_html ='';
|
105 |
+
|
106 |
+
$before_html = apply_filters( 'pib_shortcode_before', $before_html );
|
107 |
+
$html = apply_filters( 'pib_shortcode_html' , $html );
|
108 |
+
$after_html = apply_filters( 'pib_shortcode_after', $after_html );
|
109 |
+
|
110 |
+
return $before_html . $html . $after_html;
|
111 |
}
|
|
|
112 |
add_shortcode( 'pinit', 'pib_pinit_shortcode' );
|
includes/upgrade-plugin.php
CHANGED
@@ -12,6 +12,7 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
|
|
15 |
if ( ! get_option( 'pib_version' ) ) {
|
16 |
add_option( 'pib_version', $this->version );
|
17 |
} else {
|
@@ -34,6 +35,11 @@ if ( version_compare( get_option( 'pib_old_version' ), $this->version, '<' ) ) {
|
|
34 |
delete_option( 'pib_old_version' );
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
37 |
function pib_do_all_upgrades() {
|
38 |
|
39 |
$current_version = get_option( 'pib_old_version' );
|
@@ -46,6 +52,11 @@ function pib_do_all_upgrades() {
|
|
46 |
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
49 |
function pib_v2_upgrade() {
|
50 |
// Add code here to transfer all the options to new tab layout
|
51 |
|
@@ -99,5 +110,4 @@ function pib_v2_upgrade() {
|
|
99 |
}
|
100 |
}
|
101 |
}
|
102 |
-
|
103 |
pib_do_all_upgrades();
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
// Need to first check if there is currently a version option stored to compare it later
|
16 |
if ( ! get_option( 'pib_version' ) ) {
|
17 |
add_option( 'pib_version', $this->version );
|
18 |
} else {
|
35 |
delete_option( 'pib_old_version' );
|
36 |
}
|
37 |
|
38 |
+
/**
|
39 |
+
* Check and run through all necessary upgrades
|
40 |
+
*
|
41 |
+
* @since 2.0.0
|
42 |
+
*/
|
43 |
function pib_do_all_upgrades() {
|
44 |
|
45 |
$current_version = get_option( 'pib_old_version' );
|
52 |
|
53 |
}
|
54 |
|
55 |
+
/**
|
56 |
+
* Run all needed upgrades for users coming from pre-2.0.0
|
57 |
+
*
|
58 |
+
* @since 2.0.0
|
59 |
+
*/
|
60 |
function pib_v2_upgrade() {
|
61 |
// Add code here to transfer all the options to new tab layout
|
62 |
|
110 |
}
|
111 |
}
|
112 |
}
|
|
|
113 |
pib_do_all_upgrades();
|
includes/widgets.php
CHANGED
@@ -12,8 +12,18 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
15 |
class PIB_Widget extends WP_Widget {
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
public function __construct() {
|
18 |
parent::__construct(
|
19 |
'pib_button',
|
@@ -26,7 +36,12 @@ class PIB_Widget extends WP_Widget {
|
|
26 |
array( 'width' => 400 )
|
27 |
);
|
28 |
}
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
public function widget( $args, $instance ) {
|
31 |
global $pib_options;
|
32 |
extract( $args );
|
@@ -67,7 +82,7 @@ class PIB_Widget extends WP_Widget {
|
|
67 |
}
|
68 |
|
69 |
if ( $pib_remove_div ) {
|
70 |
-
|
71 |
}
|
72 |
else {
|
73 |
|
@@ -84,12 +99,23 @@ class PIB_Widget extends WP_Widget {
|
|
84 |
}
|
85 |
|
86 |
// Surround with div tag
|
87 |
-
|
88 |
}
|
89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
echo $after_widget;
|
91 |
}
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
93 |
public function update( $new_instance, $old_instance ) {
|
94 |
$instance = $old_instance;
|
95 |
|
@@ -107,7 +133,12 @@ class PIB_Widget extends WP_Widget {
|
|
107 |
|
108 |
return $instance;
|
109 |
}
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
111 |
public function form( $instance ) {
|
112 |
global $pib_options;
|
113 |
|
@@ -226,5 +257,4 @@ class PIB_Widget extends WP_Widget {
|
|
226 |
<?php
|
227 |
}
|
228 |
}
|
229 |
-
|
230 |
add_action( 'widgets_init', create_function( '', 'register_widget("PIB_Widget");' ) );
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
/**
|
16 |
+
* Class functions for the Pin It Button widgets
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
*/
|
20 |
class PIB_Widget extends WP_Widget {
|
21 |
|
22 |
+
/**
|
23 |
+
* Initialize the widget
|
24 |
+
*
|
25 |
+
* @since 2.0.0
|
26 |
+
*/
|
27 |
public function __construct() {
|
28 |
parent::__construct(
|
29 |
'pib_button',
|
36 |
array( 'width' => 400 )
|
37 |
);
|
38 |
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Public facing widget code
|
42 |
+
*
|
43 |
+
* @since 2.0.0
|
44 |
+
*/
|
45 |
public function widget( $args, $instance ) {
|
46 |
global $pib_options;
|
47 |
extract( $args );
|
82 |
}
|
83 |
|
84 |
if ( $pib_remove_div ) {
|
85 |
+
$html = $base_btn;
|
86 |
}
|
87 |
else {
|
88 |
|
99 |
}
|
100 |
|
101 |
// Surround with div tag
|
102 |
+
$html = '<div class="pin-it-btn-wrapper-widget ' . $align_class . '">' . $base_btn . '</div>';
|
103 |
}
|
104 |
|
105 |
+
do_action( 'pib_widget_before' );
|
106 |
+
|
107 |
+
echo apply_filters( 'pib_widget_html', $html );
|
108 |
+
|
109 |
+
do_action( 'pib_widget_after' );
|
110 |
+
|
111 |
echo $after_widget;
|
112 |
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Update the widget settings from user input
|
116 |
+
*
|
117 |
+
* @since 2.0.0
|
118 |
+
*/
|
119 |
public function update( $new_instance, $old_instance ) {
|
120 |
$instance = $old_instance;
|
121 |
|
133 |
|
134 |
return $instance;
|
135 |
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Display widget settings in admin
|
139 |
+
*
|
140 |
+
* @since 2.0.0
|
141 |
+
*/
|
142 |
public function form( $instance ) {
|
143 |
global $pib_options;
|
144 |
|
257 |
<?php
|
258 |
}
|
259 |
}
|
|
|
260 |
add_action( 'widgets_init', create_function( '', 'register_widget("PIB_Widget");' ) );
|
index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
pinterest-pin-it-button.php
CHANGED
@@ -6,13 +6,13 @@
|
|
6 |
* @author Phil Derksen <pderksen@gmail.com>, Nick Young <mycorpweb@gmail.com>
|
7 |
* @license GPL-2.0+
|
8 |
* @link http://pinterestplugin.com
|
9 |
-
* @copyright 2011-
|
10 |
*
|
11 |
* @wordpress-plugin
|
12 |
* Plugin Name: Pinterest "Pin It" Button Lite
|
13 |
* Plugin URI: http://pinterestplugin.com/pin-it-button-pro/
|
14 |
* Description: Add a Pinterest "Pin It" Button to your site and get your visitors to start pinning your awesome content!
|
15 |
-
* Version: 2.0.
|
16 |
* Author: Phil Derksen
|
17 |
* Author URI: http://philderksen.com
|
18 |
* License: GPL-2.0+
|
@@ -23,6 +23,7 @@
|
|
23 |
if ( ! defined( 'ABSPATH' ) )
|
24 |
exit;
|
25 |
|
|
|
26 |
if( ! class_exists( 'Pinterest_Pin_It_Button_Pro' ) ) {
|
27 |
if( ! class_exists( 'Pinterest_Pin_It_Button' ) )
|
28 |
require_once( plugin_dir_path( __FILE__ ) . 'class-pinterest-pin-it-button.php' );
|
@@ -35,3 +36,5 @@ if( ! class_exists( 'Pinterest_Pin_It_Button_Pro' ) ) {
|
|
35 |
echo "You already have Pinterest Pin It Button Pro installed. To downgrade please deactivate and delete the Pro plugin first.";
|
36 |
die();
|
37 |
}
|
|
|
|
6 |
* @author Phil Derksen <pderksen@gmail.com>, Nick Young <mycorpweb@gmail.com>
|
7 |
* @license GPL-2.0+
|
8 |
* @link http://pinterestplugin.com
|
9 |
+
* @copyright 2011-2014 Phil Derksen
|
10 |
*
|
11 |
* @wordpress-plugin
|
12 |
* Plugin Name: Pinterest "Pin It" Button Lite
|
13 |
* Plugin URI: http://pinterestplugin.com/pin-it-button-pro/
|
14 |
* Description: Add a Pinterest "Pin It" Button to your site and get your visitors to start pinning your awesome content!
|
15 |
+
* Version: 2.0.3
|
16 |
* Author: Phil Derksen
|
17 |
* Author URI: http://philderksen.com
|
18 |
* License: GPL-2.0+
|
23 |
if ( ! defined( 'ABSPATH' ) )
|
24 |
exit;
|
25 |
|
26 |
+
// Run a check for Pro first since these 2 plugins cannot be installed at the same time to avoid issues and crashes
|
27 |
if( ! class_exists( 'Pinterest_Pin_It_Button_Pro' ) ) {
|
28 |
if( ! class_exists( 'Pinterest_Pin_It_Button' ) )
|
29 |
require_once( plugin_dir_path( __FILE__ ) . 'class-pinterest-pin-it-button.php' );
|
36 |
echo "You already have Pinterest Pin It Button Pro installed. To downgrade please deactivate and delete the Pro plugin first.";
|
37 |
die();
|
38 |
}
|
39 |
+
|
40 |
+
define( 'PIB_MAIN_FILE', __FILE__ );
|
readme.txt
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
=== Pinterest "Pin It" Button ===
|
2 |
Contributors: pderksen, nickyoung87
|
3 |
-
Tags: pinterest,
|
4 |
-
Requires at least: 3.
|
5 |
-
Tested up to: 3.
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -66,7 +66,7 @@ This plugin (as well as the Pro version) is in full compliance with the [officia
|
|
66 |
|
67 |
This plugin utilizes the code output from the [official "Pin It" button widget builder](http://business.pinterest.com/widget-builder/#do_pin_it_button).
|
68 |
|
69 |
-
|
70 |
|
71 |
== Installation ==
|
72 |
|
@@ -74,7 +74,7 @@ You can install this plugin one of three ways:
|
|
74 |
|
75 |
= 1. Admin Search =
|
76 |
1. In your Admin, go to menu Plugins > Add.
|
77 |
-
1. Search for `
|
78 |
1. Find the plugin that's labeled `Pinterest "Pin It" Button` with "Pin It" in quotes.
|
79 |
1. Look for the author name `Phil Derksen` on the plugin.
|
80 |
1. Click to install.
|
@@ -122,6 +122,13 @@ CSS styling and shortcode help available within the plugin admin.
|
|
122 |
|
123 |
== Changelog ==
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
= 2.0.2 =
|
126 |
|
127 |
* Added options for colors, sizes and shapes based on Pinterest's official widget builder.
|
@@ -150,9 +157,11 @@ CSS styling and shortcode help available within the plugin admin.
|
|
150 |
* Optional Presstrends anonymous usage tracking.
|
151 |
|
152 |
= 1.4.3 =
|
|
|
153 |
* Fixed bug where Create Pin popup wasn't working in some cases.
|
154 |
|
155 |
= 1.4.2 =
|
|
|
156 |
* Tested with WordPress 3.5.
|
157 |
* Added: Option to save settings upon plugin uninstall.
|
158 |
* Changed: Removed "Always show pin count" option as it's no longer supported by Pinterest.
|
@@ -164,15 +173,18 @@ CSS styling and shortcode help available within the plugin admin.
|
|
164 |
* Fixed: Various minor bug fixes.
|
165 |
|
166 |
= 1.4.1 =
|
|
|
167 |
* Fixed: Various shortcode fixes.
|
168 |
* Fixed: Moved some JavaScript files that were loaded in the footer to now load in the header to improve compatibility with themes not implementing wp_footer().
|
169 |
* Fixed: Updated button CSS/styles to improve compatibility with more themes.
|
170 |
|
171 |
= 1.4.0 =
|
|
|
172 |
* Changed/Fixed: Iframe removed when button set to "User selects image". Fixes security issues and display errors on some web hosts.
|
173 |
* Added: Displays new features available if upgrading "Pin It" Button Pro
|
174 |
|
175 |
= 1.3.1 =
|
|
|
176 |
* Changed: Modified button JavaScript to be in line with Pinterest's current button embed JavaScript
|
177 |
* Changed: Split up internal code files for easier maintenance and updates
|
178 |
* Fixed: Shortcode -- If the attributes "url", "image_url" and/or "description" aren't specified, it will try and use the post's custom page url, image url and/or description if found. If not found it will default to the post's url, first image in post and post title.
|
@@ -180,6 +192,7 @@ CSS styling and shortcode help available within the plugin admin.
|
|
180 |
* Fixed: Uninstall now removes custom post meta fields
|
181 |
|
182 |
= 1.3.0 =
|
|
|
183 |
* Added: Added a Pin Count option (horizontal or vertical)
|
184 |
* Added: Added new button style where image is pre-selected (like official Pinterest button)
|
185 |
* Added: Added fields for specifying URL, image URL and description for new button style **image pre-selected**
|
@@ -194,9 +207,11 @@ CSS styling and shortcode help available within the plugin admin.
|
|
194 |
* Fixed: Fixed bug where tag, author, date and search archive pages were not displaying the button
|
195 |
|
196 |
= 1.2.1 =
|
|
|
197 |
* Fixed: Fixed bug with hiding posts/pages/categories when upgrading from a previous version
|
198 |
|
199 |
= 1.2.0 =
|
|
|
200 |
* Added: Added option to hide button per page/post
|
201 |
* Added: Added option to hide button per category
|
202 |
* Added: Added widget to display "Pin It" button
|
@@ -204,37 +219,47 @@ CSS styling and shortcode help available within the plugin admin.
|
|
204 |
* Fixed: Fixed CSS where some blogs weren't displaying the button properly
|
205 |
|
206 |
= 1.1.3 =
|
|
|
207 |
* Added: Added option to hide button on individual posts and pages (on post/page editing screen)
|
208 |
|
209 |
= 1.1.2 =
|
|
|
210 |
* Fixed: Removed use of session state storing for now as it caused errors for some
|
211 |
|
212 |
= 1.1.1 =
|
|
|
213 |
* Fixed: Updated jQuery coding method to avoid JavaScript conflicts with other plugins and themes some were getting
|
214 |
|
215 |
= 1.1.0 =
|
|
|
216 |
* Added: Added custom CSS area for advanced layout and styling
|
217 |
* Added: Added checkbox option to remove the button's surrounding `<div>` tag
|
218 |
* Added: Button image and style updated to match Pinterest's current embed code
|
219 |
* Fixed: Changed the way the button click is called to solve pinning issues in Internet Explorer
|
220 |
|
221 |
= 1.0.2 =
|
|
|
222 |
* Added: Added checkbox option to display/hide button on post excerpts
|
223 |
* Fixed: "Pin It" links generated by the shortcode should not show up when viewing the post in RSS readers
|
224 |
|
225 |
= 1.0.1 =
|
|
|
226 |
* Added: Added checkbox option to display/hide button on "front page" (sometimes different than home page)
|
227 |
|
228 |
= 1.0.0 =
|
|
|
229 |
* Added: Added checkbox options to select what types of pages the button should appear on
|
230 |
* Added: Display options above and below content are now checkboxes (one or both can be selected)
|
231 |
* Added: Added shortcode [pinit] to display button within content
|
232 |
|
233 |
= 0.1.2 =
|
|
|
234 |
* Changed: Moved javascript that fires on button click to a separate file
|
235 |
|
236 |
= 0.1.1 =
|
|
|
237 |
* Fixed style sheet reference
|
238 |
|
239 |
= 0.1.0 =
|
|
|
240 |
* Initial release
|
1 |
=== Pinterest "Pin It" Button ===
|
2 |
Contributors: pderksen, nickyoung87
|
3 |
+
Tags: pinterest, pin it button, social, social media, image, images, photo, photos, pinterest pin it button, pin it, social button
|
4 |
+
Requires at least: 3.6.1
|
5 |
+
Tested up to: 3.9
|
6 |
Stable tag: trunk
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
66 |
|
67 |
This plugin utilizes the code output from the [official "Pin It" button widget builder](http://business.pinterest.com/widget-builder/#do_pin_it_button).
|
68 |
|
69 |
+
[Follow this project on Github](https://github.com/pderksen/WP-Pinterest-Pin-It-Button).
|
70 |
|
71 |
== Installation ==
|
72 |
|
74 |
|
75 |
= 1. Admin Search =
|
76 |
1. In your Admin, go to menu Plugins > Add.
|
77 |
+
1. Search for `Pin It Button`.
|
78 |
1. Find the plugin that's labeled `Pinterest "Pin It" Button` with "Pin It" in quotes.
|
79 |
1. Look for the author name `Phil Derksen` on the plugin.
|
80 |
1. Click to install.
|
122 |
|
123 |
== Changelog ==
|
124 |
|
125 |
+
= 2.0.3 =
|
126 |
+
|
127 |
+
* Added action and filter hooks for extensibility.
|
128 |
+
* Fixed a bug with upgrade code being called multiple times.
|
129 |
+
* Removed PressTrends integration.
|
130 |
+
* Tested up to WordPress 3.9.
|
131 |
+
|
132 |
= 2.0.2 =
|
133 |
|
134 |
* Added options for colors, sizes and shapes based on Pinterest's official widget builder.
|
157 |
* Optional Presstrends anonymous usage tracking.
|
158 |
|
159 |
= 1.4.3 =
|
160 |
+
|
161 |
* Fixed bug where Create Pin popup wasn't working in some cases.
|
162 |
|
163 |
= 1.4.2 =
|
164 |
+
|
165 |
* Tested with WordPress 3.5.
|
166 |
* Added: Option to save settings upon plugin uninstall.
|
167 |
* Changed: Removed "Always show pin count" option as it's no longer supported by Pinterest.
|
173 |
* Fixed: Various minor bug fixes.
|
174 |
|
175 |
= 1.4.1 =
|
176 |
+
|
177 |
* Fixed: Various shortcode fixes.
|
178 |
* Fixed: Moved some JavaScript files that were loaded in the footer to now load in the header to improve compatibility with themes not implementing wp_footer().
|
179 |
* Fixed: Updated button CSS/styles to improve compatibility with more themes.
|
180 |
|
181 |
= 1.4.0 =
|
182 |
+
|
183 |
* Changed/Fixed: Iframe removed when button set to "User selects image". Fixes security issues and display errors on some web hosts.
|
184 |
* Added: Displays new features available if upgrading "Pin It" Button Pro
|
185 |
|
186 |
= 1.3.1 =
|
187 |
+
|
188 |
* Changed: Modified button JavaScript to be in line with Pinterest's current button embed JavaScript
|
189 |
* Changed: Split up internal code files for easier maintenance and updates
|
190 |
* Fixed: Shortcode -- If the attributes "url", "image_url" and/or "description" aren't specified, it will try and use the post's custom page url, image url and/or description if found. If not found it will default to the post's url, first image in post and post title.
|
192 |
* Fixed: Uninstall now removes custom post meta fields
|
193 |
|
194 |
= 1.3.0 =
|
195 |
+
|
196 |
* Added: Added a Pin Count option (horizontal or vertical)
|
197 |
* Added: Added new button style where image is pre-selected (like official Pinterest button)
|
198 |
* Added: Added fields for specifying URL, image URL and description for new button style **image pre-selected**
|
207 |
* Fixed: Fixed bug where tag, author, date and search archive pages were not displaying the button
|
208 |
|
209 |
= 1.2.1 =
|
210 |
+
|
211 |
* Fixed: Fixed bug with hiding posts/pages/categories when upgrading from a previous version
|
212 |
|
213 |
= 1.2.0 =
|
214 |
+
|
215 |
* Added: Added option to hide button per page/post
|
216 |
* Added: Added option to hide button per category
|
217 |
* Added: Added widget to display "Pin It" button
|
219 |
* Fixed: Fixed CSS where some blogs weren't displaying the button properly
|
220 |
|
221 |
= 1.1.3 =
|
222 |
+
|
223 |
* Added: Added option to hide button on individual posts and pages (on post/page editing screen)
|
224 |
|
225 |
= 1.1.2 =
|
226 |
+
|
227 |
* Fixed: Removed use of session state storing for now as it caused errors for some
|
228 |
|
229 |
= 1.1.1 =
|
230 |
+
|
231 |
* Fixed: Updated jQuery coding method to avoid JavaScript conflicts with other plugins and themes some were getting
|
232 |
|
233 |
= 1.1.0 =
|
234 |
+
|
235 |
* Added: Added custom CSS area for advanced layout and styling
|
236 |
* Added: Added checkbox option to remove the button's surrounding `<div>` tag
|
237 |
* Added: Button image and style updated to match Pinterest's current embed code
|
238 |
* Fixed: Changed the way the button click is called to solve pinning issues in Internet Explorer
|
239 |
|
240 |
= 1.0.2 =
|
241 |
+
|
242 |
* Added: Added checkbox option to display/hide button on post excerpts
|
243 |
* Fixed: "Pin It" links generated by the shortcode should not show up when viewing the post in RSS readers
|
244 |
|
245 |
= 1.0.1 =
|
246 |
+
|
247 |
* Added: Added checkbox option to display/hide button on "front page" (sometimes different than home page)
|
248 |
|
249 |
= 1.0.0 =
|
250 |
+
|
251 |
* Added: Added checkbox options to select what types of pages the button should appear on
|
252 |
* Added: Display options above and below content are now checkboxes (one or both can be selected)
|
253 |
* Added: Added shortcode [pinit] to display button within content
|
254 |
|
255 |
= 0.1.2 =
|
256 |
+
|
257 |
* Changed: Moved javascript that fires on button click to a separate file
|
258 |
|
259 |
= 0.1.1 =
|
260 |
+
|
261 |
* Fixed style sheet reference
|
262 |
|
263 |
= 0.1.0 =
|
264 |
+
|
265 |
* Initial release
|
screenshot-3.png
CHANGED
Binary file
|
screenshot-4.png
CHANGED
Binary file
|
screenshot-5.png
CHANGED
Binary file
|
screenshot-6.png
CHANGED
Binary file
|
screenshot-7.png
CHANGED
Binary file
|
views/admin-help.php
CHANGED
@@ -19,8 +19,7 @@ if ( ! defined( 'ABSPATH' ) )
|
|
19 |
<div id="pib-settings">
|
20 |
<div id="pib-settings-content">
|
21 |
|
22 |
-
<?php
|
23 |
-
<h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
|
24 |
|
25 |
<p>
|
26 |
<?php _e( 'Plugin version', 'pib' ); ?>: <strong><?php echo PIB_VERSION; ?></strong>
|
@@ -207,6 +206,15 @@ if ( ! defined( 'ABSPATH' ) )
|
|
207 |
<li><code>div.pin-it-btn-wrapper-widget a { border: 1px solid red; }</code> - <?php _e( 'Add red border around widget button', 'pib' ); ?></li>
|
208 |
</ul>
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
<p>
|
211 |
<?php printf( __( 'Visit the <a href="%s" target="_blank">Knowledgebase</a> for additional help.', 'pib' ), 'http://pinterestplugin.com/support' ); ?>
|
212 |
</p>
|
19 |
<div id="pib-settings">
|
20 |
<div id="pib-settings-content">
|
21 |
|
22 |
+
<h2><img src="<?php echo PIB_PLUGIN_URL; ?>assets/pinterest-icon-32.png" style="vertical-align: bottom;" /> <?php echo esc_html( get_admin_page_title() ); ?></h2>
|
|
|
23 |
|
24 |
<p>
|
25 |
<?php _e( 'Plugin version', 'pib' ); ?>: <strong><?php echo PIB_VERSION; ?></strong>
|
206 |
<li><code>div.pin-it-btn-wrapper-widget a { border: 1px solid red; }</code> - <?php _e( 'Add red border around widget button', 'pib' ); ?></li>
|
207 |
</ul>
|
208 |
|
209 |
+
<p>
|
210 |
+
<?php printf( __( 'Need more widgets? Check out our free <a href="%s">Pinterest Widgets</a> plugin.', 'pib' ),
|
211 |
+
add_query_arg( array(
|
212 |
+
'tab' => 'search',
|
213 |
+
'type' => 'term',
|
214 |
+
's' => urlencode('pinterest widgets')
|
215 |
+
), admin_url( 'plugin-install.php' ) )
|
216 |
+
); ?>
|
217 |
+
</p>
|
218 |
<p>
|
219 |
<?php printf( __( 'Visit the <a href="%s" target="_blank">Knowledgebase</a> for additional help.', 'pib' ), 'http://pinterestplugin.com/support' ); ?>
|
220 |
</p>
|
views/admin-sidebar.php
CHANGED
@@ -41,9 +41,6 @@ if ( ! defined( 'ABSPATH' ) )
|
|
41 |
class="btn btn-large btn-block btn-danger" target="_blank">
|
42 |
<?php _e( 'Upgrade to Pro Now', 'pib' ); ?></a>
|
43 |
<br/>
|
44 |
-
<p style="text-align: center;">
|
45 |
-
<?php _e( 'Enter discount code <strong>HOLIDAY2013</strong> to get a <strong>10% discount</strong> until Dec 31, 2013!', 'pib' ); ?>
|
46 |
-
</p>
|
47 |
</div>
|
48 |
</div>
|
49 |
|
41 |
class="btn btn-large btn-block btn-danger" target="_blank">
|
42 |
<?php _e( 'Upgrade to Pro Now', 'pib' ); ?></a>
|
43 |
<br/>
|
|
|
|
|
|
|
44 |
</div>
|
45 |
</div>
|
46 |
|
views/admin.php
CHANGED
@@ -26,8 +26,8 @@ $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
|
|
26 |
<div id="pib-settings">
|
27 |
<div id="pib-settings-content">
|
28 |
|
29 |
-
|
30 |
-
<h2
|
31 |
|
32 |
<h2 class="nav-tab-wrapper">
|
33 |
<a href="<?php echo add_query_arg( 'tab', 'general', remove_query_arg( 'settings-updated' )); ?>" class="nav-tab
|
26 |
<div id="pib-settings">
|
27 |
<div id="pib-settings-content">
|
28 |
|
29 |
+
|
30 |
+
<h2><img src="<?php echo PIB_PLUGIN_URL; ?>assets/pinterest-icon-32.png" style="vertical-align: bottom;" /> <?php echo esc_html( get_admin_page_title() ); ?></h2>
|
31 |
|
32 |
<h2 class="nav-tab-wrapper">
|
33 |
<a href="<?php echo add_query_arg( 'tab', 'general', remove_query_arg( 'settings-updated' )); ?>" class="nav-tab
|
views/index.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
<?php // Silence is golden
|
1 |
+
<?php // Silence is golden
|
views/post-meta-display.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
-
global $pib_options, $post;
|
16 |
|
17 |
$button_type_display = ( $pib_options['button_type'] == 'user_selects_image' ) ? __( 'User selects image', 'pib' ) : __( 'Image pre-selected', 'pib' );
|
18 |
|
@@ -51,13 +51,13 @@ $pib_description = get_post_meta( $post->ID, 'pib_description', true);
|
|
51 |
</p>
|
52 |
<p>
|
53 |
<input type="checkbox" name="pib_enable_post_sharing" id="pib_enable_post_sharing" <?php checked( empty( $pib_sharing_checked ) || ($pib_sharing_checked === false) ); ?> />
|
54 |
-
<label for="pib_enable_post_sharing"><?php _e( 'Show "Pin It" button on this post/page', 'pib' ); ?></label>
|
55 |
</p>
|
56 |
<p class="description">
|
57 |
-
<?php _e( 'If checked displays the button for this post (if Individual Posts selected) or this page (if Individual Pages selected) in the main "Pin It" button settings.', 'pib' ); ?>
|
58 |
</p>
|
59 |
<p class="description">
|
60 |
-
<?php _e( 'If unchecked the button will always be hidden for this post/page.', 'pib' ); ?>
|
61 |
</p>
|
62 |
|
63 |
<input type="hidden" name="pib_sharing_status_hidden" value="1" />
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
global $pib_options, $post, $pib_vars;
|
16 |
|
17 |
$button_type_display = ( $pib_options['button_type'] == 'user_selects_image' ) ? __( 'User selects image', 'pib' ) : __( 'Image pre-selected', 'pib' );
|
18 |
|
51 |
</p>
|
52 |
<p>
|
53 |
<input type="checkbox" name="pib_enable_post_sharing" id="pib_enable_post_sharing" <?php checked( empty( $pib_sharing_checked ) || ($pib_sharing_checked === false) ); ?> />
|
54 |
+
<label for="pib_enable_post_sharing"><?php _e( 'Show "Pin It" button ' . $pib_vars['post_meta_message'] . ' on this post/page', 'pib' ); ?></label>
|
55 |
</p>
|
56 |
<p class="description">
|
57 |
+
<?php _e( 'If checked displays the button ' . $pib_vars['post_meta_message'] . ' for this post (if Individual Posts selected) or this page (if Individual Pages selected) in the main "Pin It" button settings.', 'pib' ); ?>
|
58 |
</p>
|
59 |
<p class="description">
|
60 |
+
<?php _e( 'If unchecked the button ' . $pib_vars['post_meta_message'] . ' will always be hidden for this post/page.', 'pib' ); ?>
|
61 |
</p>
|
62 |
|
63 |
<input type="hidden" name="pib_sharing_status_hidden" value="1" />
|
views/public.php
CHANGED
@@ -12,7 +12,12 @@
|
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
function pib_add_custom_css() {
|
17 |
global $pib_options;
|
18 |
|
@@ -28,15 +33,18 @@ function pib_add_custom_css() {
|
|
28 |
}
|
29 |
add_action( 'wp_head', 'pib_add_custom_css' );
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
40 |
function pib_button_base( $button_type, $post_url, $image_url, $description, $count_layout, $size, $color, $shape, $show_zero_count = null ) {
|
41 |
global $pib_options;
|
42 |
global $post;
|
@@ -46,7 +54,8 @@ function pib_button_base( $button_type, $post_url, $image_url, $description, $co
|
|
46 |
$btn_img_url = '//assets.pinterest.com/images/pidgets/pin_it_button.png';
|
47 |
|
48 |
// Add "Pin It" title attribute.
|
49 |
-
|
|
|
50 |
|
51 |
// Set data attribute for button style.
|
52 |
if ( $button_type == 'image_selected' )
|
@@ -108,9 +117,7 @@ function pib_button_base( $button_type, $post_url, $image_url, $description, $co
|
|
108 |
// Check main settings option and set accordingly
|
109 |
$display_zero = ( ! empty( $pib_options['show_zero_count'] ) ? 'data-pin-zero="true" ' : ' ' );
|
110 |
}
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
// Full link html with data attributes.
|
115 |
// Add rel="nobox" to prevent lightbox popup.
|
116 |
$link_html = '<a href="' . $link_href . '" ' .
|
@@ -126,8 +133,13 @@ function pib_button_base( $button_type, $post_url, $image_url, $description, $co
|
|
126 |
return $link_html;
|
127 |
}
|
128 |
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
|
|
131 |
global $pib_options;
|
132 |
global $post;
|
133 |
$postID = $post->ID;
|
@@ -149,17 +161,37 @@ function pib_button_html( $image_url = '' ) {
|
|
149 |
$size = ( ! empty( $pib_options['data_pin_size'] ) ? $pib_options['data_pin_size'] : '' );
|
150 |
$color = ( ! empty( $pib_options['data_pin_color'] ) ? $pib_options['data_pin_color'] : '' );
|
151 |
$shape = ( ! empty( $pib_options['data_pin_shape'] ) ? $pib_options['data_pin_shape'] : '' );
|
|
|
|
|
|
|
|
|
152 |
|
153 |
-
$base_btn = pib_button_base( $
|
154 |
|
155 |
// Don't wrap with div if using other sharing buttons or "remove div" is checked.
|
156 |
if ( ! empty( $pib_options['remove_div'] ) )
|
157 |
-
|
158 |
else
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
}
|
161 |
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
163 |
function pib_render_content( $content ) {
|
164 |
global $pib_options;
|
165 |
global $post;
|
@@ -171,7 +203,7 @@ function pib_render_content( $content ) {
|
|
171 |
if (
|
172 |
( is_home() && ( ! empty( $pib_options['post_page_types']['display_home_page'] ) ) ) ||
|
173 |
( is_front_page() && ( ! empty( $pib_options['post_page_types']['display_front_page'] ) ) ) ||
|
174 |
-
|
175 |
( is_page() && ( ! empty( $pib_options['post_page_types']['display_pages'] ) ) && !is_front_page() ) ||
|
176 |
|
177 |
//archive pages besides categories (tag, author, date, search)
|
@@ -190,9 +222,14 @@ function pib_render_content( $content ) {
|
|
190 |
|
191 |
return $content;
|
192 |
}
|
193 |
-
add_filter( 'the_content', 'pib_render_content' );
|
194 |
|
195 |
-
|
|
|
|
|
|
|
|
|
|
|
196 |
function pib_render_content_excerpt( $content ) {
|
197 |
global $pib_options;
|
198 |
global $post;
|
@@ -217,4 +254,4 @@ function pib_render_content_excerpt( $content ) {
|
|
217 |
|
218 |
return $content;
|
219 |
}
|
220 |
-
add_filter( 'the_excerpt', 'pib_render_content_excerpt' );
|
12 |
if ( ! defined( 'ABSPATH' ) )
|
13 |
exit;
|
14 |
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Add Custom CSS.
|
18 |
+
*
|
19 |
+
* @since 2.0.0
|
20 |
+
*/
|
21 |
function pib_add_custom_css() {
|
22 |
global $pib_options;
|
23 |
|
33 |
}
|
34 |
add_action( 'wp_head', 'pib_add_custom_css' );
|
35 |
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Function for rendering "Pin It" button base html.
|
39 |
+
* HTML comes from Pinterest Widget Builder 7/10/2013.
|
40 |
+
* http://business.pinterest.com/widget-builder/#do_pin_it_button
|
41 |
+
* Sample HTML from widget builder:
|
42 |
+
* <a href="//www.pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg&description=Next%20stop%3A%20Pinterest" data-pin-do="buttonPin" data-pin-config="above">
|
43 |
+
* <img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" />
|
44 |
+
* </a>
|
45 |
+
*
|
46 |
+
* @since 2.0.0
|
47 |
+
*/
|
48 |
function pib_button_base( $button_type, $post_url, $image_url, $description, $count_layout, $size, $color, $shape, $show_zero_count = null ) {
|
49 |
global $pib_options;
|
50 |
global $post;
|
54 |
$btn_img_url = '//assets.pinterest.com/images/pidgets/pin_it_button.png';
|
55 |
|
56 |
// Add "Pin It" title attribute.
|
57 |
+
// Also add our own data attribute to track pin it button images.
|
58 |
+
$inner_btn_html = '<img src="' . $btn_img_url . '" title="Pin It" data-pib-button="true" />';
|
59 |
|
60 |
// Set data attribute for button style.
|
61 |
if ( $button_type == 'image_selected' )
|
117 |
// Check main settings option and set accordingly
|
118 |
$display_zero = ( ! empty( $pib_options['show_zero_count'] ) ? 'data-pin-zero="true" ' : ' ' );
|
119 |
}
|
120 |
+
|
|
|
|
|
121 |
// Full link html with data attributes.
|
122 |
// Add rel="nobox" to prevent lightbox popup.
|
123 |
$link_html = '<a href="' . $link_href . '" ' .
|
133 |
return $link_html;
|
134 |
}
|
135 |
|
136 |
+
/**
|
137 |
+
* Button HTML to render for pages, posts, and excerpts.
|
138 |
+
*
|
139 |
+
* @since 2.0.0
|
140 |
+
*
|
141 |
+
*/
|
142 |
+
function pib_button_html( $image_url = '', $button_type = '' ) {
|
143 |
global $pib_options;
|
144 |
global $post;
|
145 |
$postID = $post->ID;
|
161 |
$size = ( ! empty( $pib_options['data_pin_size'] ) ? $pib_options['data_pin_size'] : '' );
|
162 |
$color = ( ! empty( $pib_options['data_pin_color'] ) ? $pib_options['data_pin_color'] : '' );
|
163 |
$shape = ( ! empty( $pib_options['data_pin_shape'] ) ? $pib_options['data_pin_shape'] : '' );
|
164 |
+
|
165 |
+
if( empty( $button_type ) ) {
|
166 |
+
$button_type = $pib_options['button_type'];
|
167 |
+
}
|
168 |
|
169 |
+
$base_btn = pib_button_base( $button_type, $post_url, $image_url, $description, $count_layout, $size, $color, $shape );
|
170 |
|
171 |
// Don't wrap with div if using other sharing buttons or "remove div" is checked.
|
172 |
if ( ! empty( $pib_options['remove_div'] ) )
|
173 |
+
$html = $base_btn;
|
174 |
else
|
175 |
+
$html = '<div class="pin-it-btn-wrapper">' . $base_btn . '</div>'; // Surround with div tag
|
176 |
+
|
177 |
+
|
178 |
+
$before_html = '';
|
179 |
+
$after_html = '';
|
180 |
+
|
181 |
+
$before_html = apply_filters( 'pib_button_before', $before_html );
|
182 |
+
$html = apply_filters( 'pib_button_html', $html );
|
183 |
+
$after_html = apply_filters( 'pib_button_after', $after_html );
|
184 |
+
|
185 |
+
|
186 |
+
return $before_html . $html . $after_html;
|
187 |
}
|
188 |
|
189 |
+
/**
|
190 |
+
* Render button HTML on pages with regular content.
|
191 |
+
*
|
192 |
+
* @since 2.0.0
|
193 |
+
*
|
194 |
+
*/
|
195 |
function pib_render_content( $content ) {
|
196 |
global $pib_options;
|
197 |
global $post;
|
203 |
if (
|
204 |
( is_home() && ( ! empty( $pib_options['post_page_types']['display_home_page'] ) ) ) ||
|
205 |
( is_front_page() && ( ! empty( $pib_options['post_page_types']['display_front_page'] ) ) ) ||
|
206 |
+
( is_single() && ( ! empty( $pib_options['post_page_types']['display_posts'] ) ) ) ||
|
207 |
( is_page() && ( ! empty( $pib_options['post_page_types']['display_pages'] ) ) && !is_front_page() ) ||
|
208 |
|
209 |
//archive pages besides categories (tag, author, date, search)
|
222 |
|
223 |
return $content;
|
224 |
}
|
225 |
+
add_filter( 'the_content', 'pib_render_content', 100 );
|
226 |
|
227 |
+
/**
|
228 |
+
* Render button HTML on pages with excerpts if option checked.
|
229 |
+
*
|
230 |
+
* @since 2.0.0
|
231 |
+
*
|
232 |
+
*/
|
233 |
function pib_render_content_excerpt( $content ) {
|
234 |
global $pib_options;
|
235 |
global $post;
|
254 |
|
255 |
return $content;
|
256 |
}
|
257 |
+
add_filter( 'the_excerpt', 'pib_render_content_excerpt', 100 );
|