<?php
/**
 * Plugin Name: ShareThis Reaction Buttons
 * Plugin URI: https://www.sharethis.com/platform/reaction-buttons-wordpress/
 * Description: Integrates the ShareThis Reaction Buttons directly into your website.
 * Version: 1.3.5
 * Author: ShareThis
 * Author URI: https://sharethis.com/
 * Text Domain: sharethis-reaction-buttons
 * Domain Path: /languages
 * License: GPL v2 or later
 *
 * Copyright 2026 ShareThis
 *
 * This program 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
 * (at your option) any later version.
 *
 * This program 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.
 *
 * @package ShareThisReactionButtons
 */

/**
 * Reaction Buttons version.
 */

if ( ! defined( 'ABSPATH' ) ) exit;

const SHARETHIS_REACTION_BUTTONS_VERSION = '1.3.5';

if ( version_compare( phpversion(), '5.3', '>=' ) ) {
	require_once __DIR__ . '/instance.php';
} else {
	if ( defined( 'WP_CLI' ) ) {
		WP_CLI::warning( sharethis_reaction_buttons_php_version_text() );
	} else {
		add_action( 'admin_notices', 'sharethis_reaction_buttons_php_version_error' );
	}
}

/**
 * Admin notice for incompatible versions of PHP.
 */
function sharethis_reaction_buttons_php_version_error() {
	printf( '<div class="error"><p>%s</p></div>', esc_html( sharethis_reaction_buttons_php_version_text() ) );
}

/**
 * String describing the minimum PHP version.
 *
 * @return string
 */
function sharethis_reaction_buttons_php_version_text() {
	return 'Sharethis Reaction Buttons plugin error: Your version of PHP is too old to run this plugin. You must be running PHP 5.3 or higher.';
}

/**
 * The helper function to insert the proper reaction button container.
 *
 * @return string
 */
function sharethis_reaction_buttons() {
	return '<div class="sharethis-inline-reaction-buttons"></div>';
}

add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'sharethis_reaction_buttons_add_action_links' );

/**
 * Add a link to the settings page.
 *
 * @param string $links The links shown in the plugin page.
 *
 * @return array
 */
function sharethis_reaction_buttons_add_action_links( $links ) {
	$mylinks = array(
		'<a href="' . admin_url( 'admin.php?page=sharethis-share-buttons' ) . '">Settings</a>',
	);
	return array_merge( $links, $mylinks );
}
