-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocial-sharer-for-woo.php
148 lines (122 loc) · 4.77 KB
/
social-sharer-for-woo.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/*
Plugin Name: Social Sharer for Woo
Plugin URI : https://wordpress.org/plugins/social-sharer-for-woo/
Description: Add attractive & responsive social sharing icons with link to your woocommerce product pages.
Version: 1.0.0
Author: Sajjad Hossain Sagor
Author URI: https://sajjadhsagor.com/
Text Domain: social-sharer-for-woo
License: GPL2
This WordPress Plugin is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
any later version.
This free software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this software. If not, see http://www.gnu.org/licenses/gpl-2.0.html.
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
if( ! defined( 'SSFWC_SOCIAL_SHARER_FOR_WC_ROOT_DIR' ) )
{
define( 'SSFWC_SOCIAL_SHARER_FOR_WC_ROOT_DIR', dirname( __FILE__ ) ); // Plugin root dir
}
if( ! defined( 'SSFWC_SOCIAL_SHARER_FOR_WC_ROOT_URL' ) )
{
define( 'SSFWC_SOCIAL_SHARER_FOR_WC_ROOT_URL', plugin_dir_url( __FILE__ ) ); // Plugin root url
}
if( ! defined( 'SSFWC_SOCIAL_SHARER_FOR_WC_VERSION' ) )
{
define( 'SSFWC_SOCIAL_SHARER_FOR_WC_VERSION', '1.0.0' ); // Plugin current version
}
if( ! defined( 'SSFWC_SOCIAL_SHARER_FOR_WC_OPTION_NAME' ) )
{
define( 'SSFWC_SOCIAL_SHARER_FOR_WC_OPTION_NAME', 'ssfwc_settings' ); // Plugin option name
}
if( ! defined( 'SSFWC_SOCIAL_SHARER_FOR_WC_PLUGIN_URL' ) )
{
define( 'SSFWC_SOCIAL_SHARER_FOR_WC_PLUGIN_URL', __FILE__ ); // Plugin url
}
/**
* Plugin Activation Hook
*/
register_activation_hook( __FILE__, 'ssfwc_social_sharer_for_wc_plugin_activated' );
if ( ! function_exists( 'ssfwc_social_sharer_for_wc_plugin_activated' ) )
{
function ssfwc_social_sharer_for_wc_plugin_activated()
{
if ( function_exists( 'ssfw_check_woocommerce_activation_status' ) )
{
ssfw_check_woocommerce_activation_status();
}
}
}
/**
* Plugin Deactivation Hook
*/
register_deactivation_hook( __FILE__, 'ssfwc_social_sharer_for_wc_plugin_deactivated' );
if ( ! function_exists( 'ssfwc_social_sharer_for_wc_plugin_deactivated' ) )
{
function ssfwc_social_sharer_for_wc_plugin_deactivated() {}
}
/**
* Plugin Uninstalled / Deleted Hook
*/
register_uninstall_hook( __FILE__, 'ssfwc_social_sharer_for_wc_plugin_uninstalled' );
if ( ! function_exists( 'ssfwc_social_sharer_for_wc_plugin_uninstalled' ) )
{
function ssfwc_social_sharer_for_wc_plugin_uninstalled() {}
}
/**
* This gets the plugin ready for translation
*/
add_action( 'plugins_loaded', 'ssfwc_social_sharer_for_wc_load_textdomain' );
if ( ! function_exists( 'ssfwc_social_sharer_for_wc_load_textdomain' ) )
{
function ssfwc_social_sharer_for_wc_load_textdomain()
{
load_plugin_textdomain( 'social-sharer-for-woo', '', dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
}
/**
* Add Go To Settings Page in Plugin List Table
*/
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'ssfwc_social_sharer_for_wc_goto_settings_page_link' );
if ( ! function_exists( 'ssfwc_social_sharer_for_wc_goto_settings_page_link' ) )
{
function ssfwc_social_sharer_for_wc_goto_settings_page_link( $links )
{
$goto_settings_link = [ '<a href="' . admin_url( 'admin.php?page=social-sharer-for-woo' ) . '">'. __( 'Settings', 'social-sharer-for-woo' ) .'</a>' ];
return array_merge( $links, $goto_settings_link );
}
}
/**
* Checking if Woocommerce is either installed or active
*/
add_filter( 'admin_init', 'ssfw_check_woocommerce_activation_status' );
if ( ! function_exists( 'ssfw_check_woocommerce_activation_status' ) )
{
function ssfw_check_woocommerce_activation_status()
{
if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
{
// Deactivate the plugin
deactivate_plugins( __FILE__ );
// Throw an error in the wordpress admin console
$error_message = __( 'Social Sharer for WooComerce requires <a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a> plugin to be active! <a href="javascript:history.back()"> Go back & activate Woocommerce. </a>', 'social-sharer-for-woo' );
wp_die( $error_message, __( 'WooCommerce Plugin Not Found', 'social-sharer-for-woo' ) );
}
}
}
/**
* Include plugin settings
*/
require SSFWC_SOCIAL_SHARER_FOR_WC_ROOT_DIR . '/includes/class.plugin.settings.php';
/**
* Show Buttons to Front Page
*/
require SSFWC_SOCIAL_SHARER_FOR_WC_ROOT_DIR . '/includes/class.render.front.icons.php';