PluginProbe
Share This Image / 2.16
Share This Image v2.16
2.16 2.15 1.77 1.78 1.79 1.80 1.81 1.82 1.83 1.84 1.85 1.86 1.87 1.88 1.89 1.90 1.91 1.92 1.93 1.94 1.95 1.96 1.97 1.98 1.99 All 118 releases
share-this-image / share-this-image.php

share-this-image.php in Share This Image 2.16, at share-this-image.php

321 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Plugin Name: Share This Image
5 Description: Allows you to share in social networks any of your images
6 Version: 2.16
7 Author: ILLID
8 Plugin URI: https://share-this-image.com/
9 Author URI: https://share-this-image.com/
10 Text Domain: share-this-image
11 */
12
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 define( 'STI_VER', '2.16' );
19
20
21 define( 'STI_DIR', dirname( __FILE__ ) );
22 define( 'STI_URL', plugins_url( '', __FILE__ ) );
23
24
25 if ( ! class_exists( 'STI_Main' ) ) :
26
27 /**
28 * Main plugin class
29 *
30 * @class STI_Main
31 */
32 final class STI_Main {
33
34 /**
35 * @var STI_Main The single instance of the class
36 */
37 protected static $_instance = null;
38
39 /**
40 * @var STI_Main Array of all plugin data $data
41 */
42 private $data = array();
43
44 /**
45 * Main STI_Main Instance
46 *
47 * Ensures only one instance of STI_Main is loaded or can be loaded.
48 *
49 * @static
50 * @return STI_Main - Main instance
51 */
52 public static function instance() {
53 if ( is_null( self::$_instance ) ) {
54 self::$_instance = new self();
55 }
56 return self::$_instance;
57 }
58
59 /**
60 * Constructor
61 */
62 public function __construct() {
63
64 $this->data['settings'] = get_option( 'sti_settings' );
65
66 $this->includes();
67
68 add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
69
70 add_filter( 'plugin_row_meta', array( $this, 'extra_meta_links'), 10, 2 );
71
72 add_action( 'admin_head', array( $this, 'add_meta_styles' ) );
73
74 load_plugin_textdomain( 'share-this-image', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
75
76 add_action( 'init', array( $this, 'init' ), 1 );
77
78 }
79
80 /**
81 * Include required core files used in admin and on the frontend
82 */
83 private function includes() {
84
85 include_once( 'includes/class-sti-versions.php' );
86 include_once( 'includes/class-sti-helpers.php' );
87 include_once( 'includes/class-sti-conditions.php' );
88 include_once( 'includes/class-sti-functions.php' );
89 include_once( 'includes/class-sti-integrations.php' );
90 include_once( 'includes/class-sti-shortcodes.php' );
91 include_once( 'includes/class-sti-shortlink.php' );
92
93 // Admin
94 include_once( 'includes/admin/class-sti-admin-notices.php' );
95 include_once( 'includes/admin/class-sti-admin.php' );
96 include_once( 'includes/admin/class-sti-admin-display-rules.php' );
97 include_once( 'includes/admin/class-sti-admin-fields.php' );
98 include_once( 'includes/admin/class-sti-admin-page-premium.php' );
99 include_once( 'includes/admin/class-sti-admin-helpers.php' );
100 include_once( 'includes/admin/class-sti-admin-ajax.php' );
101 include_once( 'includes/admin/class-sti-admin-options.php' );
102 include_once( 'includes/admin/class-sti-admin-meta-boxes.php' );
103
104 }
105
106 /*
107 * Add settings link to plugins
108 */
109 public function add_settings_link( $links, $file ) {
110 $plugin_base = plugin_basename( __FILE__ );
111
112 if ( $file == $plugin_base ) {
113 $setting_link = '<a href="' . admin_url('admin.php?page=sti-options') . '">'.esc_html__( 'Settings', 'share-this-image' ).'</a>';
114 array_unshift( $links, $setting_link );
115
116 $premium_link = '<a href="' . admin_url( 'admin.php?page=sti-options&tab=premium' ) . '">'.esc_html__( 'Premium Version', 'share-this-image' ).'</a>';
117 array_unshift( $links, $premium_link );
118 }
119
120 return $links;
121 }
122
123 /*
124 * Adds extra links to the plugin activation page
125 */
126 public function extra_meta_links( $meta, $file ) {
127 $plugin_base = plugin_basename( __FILE__ );
128
129 if ( $file == $plugin_base ) {
130 $meta[] = '<a class="sti-stars" href="https://wordpress.org/support/plugin/share-this-image/reviews/?rate=5#new-post" target="_blank" title="' . __( 'Leave a review', 'share-this-image' ) . '"></a>';
131 }
132
133 return $meta;
134 }
135
136 /*
137 * Add styles for plugins page
138 */
139 public function add_meta_styles() {
140 global $pagenow;
141
142 if ( $pagenow === 'plugins.php' ) {
143
144 echo "<style>";
145 echo ".sti-stars {";
146 echo "background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAYAAABy6+R8AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDE0IDc5LjE1Njc5NywgMjAxNC8wOC8yMC0wOTo1MzowMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTQgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjczN0NBQ0M4REI0NzExRTVBRkM4QjEwRTYzMEU5NzgwIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjczN0NBQ0M5REI0NzExRTVBRkM4QjEwRTYzMEU5NzgwIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NzM3Q0FDQzZEQjQ3MTFFNUFGQzhCMTBFNjMwRTk3ODAiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NzM3Q0FDQzdEQjQ3MTFFNUFGQzhCMTBFNjMwRTk3ODAiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz56rxCSAAABCklEQVR42mL8//8/AwZYzcgGJNmB+AtDKKYCJgbswACI84CYC5skLk1mQFwMxPzEaVrNyAIknYBYEIitsWli/L+KgQdIywPxNyAGuV8diFcAsQAQbwPiLKhaZiAGGfgQpEkcyGgDYk+wxxnAhkhCFf4F4ttQDYxA3AvEyxjBobeaURbImQjEgTj8CNJcAcSTgKH5ixEe5JBgrgPiajQNr4A4Cah4K8JPyNGwmtEYSJ6GOgUGToADJPT/P1yhFwjVADJ9B1RMA4it8AV5ABCfA2I/IA4D4mxoXNmhBjnCTyATo4B4MtApr5Gc7AwkjYB4GlD8K7omUGT+Bkp8wRLhokDyE1DuJ4gLEGAARw5K1iodv/cAAAAASUVORK5CYII=');";
147 echo "background-position: 0 0;";
148 echo "font-size: 0;";
149 echo "background-size: 13px 13px;";
150 echo "height: 13px;";
151 echo "display: inline-block;";
152 echo "width: 65px;";
153 echo "position: relative;";
154 echo "top: 2px;";
155 echo "}";
156 echo "</style>";
157 }
158
159 }
160
161 /*
162 * Init plugin classes
163 */
164 public function init() {
165
166 STI_Integrations::instance();
167
168 STI_Shortlink::instance();
169
170 }
171
172 /*
173 * Get plugin settings
174 */
175 public function get_settings( $name = false ) {
176 $plugin_options = $this->data['settings'];
177 $return_value = ! $name ? $plugin_options : ( isset( $plugin_options[ $name ] ) ? $plugin_options[ $name ] : false );
178 return $return_value;
179 }
180
181 }
182
183 endif;
184
185
186 /**
187 * Returns the main instance of STI_Main
188 *
189 * @return STI_Main
190 */
191 function STI() {
192 return STI_Main::instance();
193 }
194
195 /*
196 * Activation hook
197 */
198 register_activation_hook( __FILE__, 'sti_activation_check' );
199 function sti_activation_check() {
200
201 if ( sti_is_plugin_active( 'share-this-image-pro/share-this-image-pro.php' ) ) {
202 deactivate_plugins( plugin_basename( __FILE__ ) );
203 wp_die( __( 'Share This Image plugin can\'t be activated because you already activate PRO plugin version.', 'share-this-image' ) );
204 }
205
206 $hide_notice = get_option( 'sti_hide_welcome_notice' );
207 if ( ! $hide_notice ) {
208 $free_plugin_version = get_option( 'sti_plugin_ver' );
209 $pro_plugin_version = get_option( 'sti_pro_plugin_ver' );
210 $hide = 'false';
211 if ( $free_plugin_version || $pro_plugin_version ) {
212 $hide = 'true';
213 }
214 update_option( 'sti_hide_welcome_notice', $hide, false );
215 }
216
217 }
218
219 /*
220 * Check if WooCommerce is active
221 */
222 if ( ! sti_is_plugin_active( 'share-this-image-pro/share-this-image-pro.php' ) ) {
223 STI();
224 }
225
226 /*
227 * Check whether the plugin is active by checking the active_plugins list.
228 */
229 function sti_is_plugin_active( $plugin ) {
230 return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || sti_is_plugin_active_for_network( $plugin );
231 }
232
233 /*
234 * Check whether the plugin is active for the entire network
235 */
236 function sti_is_plugin_active_for_network( $plugin ) {
237 if ( !is_multisite() )
238 return false;
239
240 $plugins = get_site_option( 'active_sitewide_plugins' );
241 if ( isset($plugins[$plugin]) )
242 return true;
243
244 return false;
245 }
246
247 // Freemius
248 if ( ! function_exists( 'sti_fs' ) ) {
249 function sti_fs() {
250 global $sti_fs;
251
252 if ( ! isset( $sti_fs ) ) {
253 require_once dirname(__FILE__) . '/freemius/start.php';
254
255 $sti_fs = fs_dynamic_init( array(
256 'id' => '7106',
257 'slug' => 'share-this-image',
258 'premium_slug' => 'share-this-image-pro',
259 'type' => 'plugin',
260 'public_key' => 'pk_218e18e87b9c8be03e916c5e4bcca',
261 'is_premium' => false,
262 'premium_suffix' => 'PRO',
263 'has_premium_version' => true,
264 'has_addons' => false,
265 'has_paid_plans' => true,
266 'menu' => array(
267 'slug' => 'sti-options',
268 'first-path' => 'admin.php?page=sti-options',
269 'contact' => false,
270 'support' => false,
271 ),
272 ) );
273 }
274
275 return $sti_fs;
276 }
277
278 // Init Freemius.
279 sti_fs();
280 // Signal that SDK was initiated.
281 do_action( 'sti_fs_loaded' );
282
283 // FS uninstall hook
284 sti_fs()->add_action('after_uninstall', 'sti_fs_uninstall_cleanup');
285 function sti_fs_uninstall_cleanup() {
286 delete_option('sti_settings');
287 }
288
289 function sti_fs_custom_connect_message_on_update( $message, $user_first_name, $plugin_title, $user_login, $site_link, $freemius_link ) {
290 return sprintf(
291 __( 'Hey %1$s' ) . ',<br>' .
292 __( 'Please help us improve %2$s! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'share-this-image' ),
293 $user_first_name,
294 '<b>' . $plugin_title . '</b>',
295 '<b>' . $user_login . '</b>',
296 $site_link,
297 $freemius_link
298 );
299 }
300 sti_fs()->add_filter('connect_message_on_update', 'sti_fs_custom_connect_message_on_update', 10, 6);
301
302 function sti_fs_custom_connect_message( $message, $user_first_name, $plugin_title, $user_login, $site_link, $freemius_link ) {
303 return sprintf(
304 __( 'Hey %1$s' ) . '!<br><br>
305 <p>Thank you for trying out our plugin!</p><br>
306 <p>%2$s use Freemius.com for better user experience. Please help us make your journey even better by sharing some non-sensitive usage data.</p><br>
307 <p>Click on \'Allow and Continue\' (blue button) so that we can learn how to improve our plugin and help you better when you have support issues.</p><br>
308 <p>You can always use %2$s without opting-in. Just click \'Skip\' (white button) if you don\'t want to opt-in.</p><br>
309 <b>Regards</b></p>',
310 $user_first_name,
311 '<b>' . $plugin_title . '</b>',
312 '<b>' . $user_login . '</b>',
313 $site_link,
314 $freemius_link
315 );
316 }
317 sti_fs()->add_filter('connect_message', 'sti_fs_custom_connect_message', 10, 6);
318
319 sti_fs()->add_filter( 'show_deactivation_subscription_cancellation', '__return_false' );
320
321 }