PluginProbe
Metricool – Social media and site statistics / 2.1.1
Metricool – Social media and site statistics v2.1.1
2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
← All changes | metricool.php +35 -194 1.27 → 2.1.1 View file →
@@ -1,200 +1,41 @@
1 1 <?php
2 - /**
3 - * Plugin Name: Metricool
4 - * Plugin URI: https://metricool.com/
5 - * Version: 1.27
6 - * Author: Metricool
7 - * Author URI: https://www.metricool.com/
8 - * Description: Allows you to track your users and readers using metricool.com
9 - * License: GPL2
10 - */
11 2
12 - /* Copyright 2021 Metricool
3 +/**
4 + * @package Metricool
5 + * @author Really Simple Plugins
6 + * @copyright 2026 Really Simple Plugins
7 + * @license GPL-2.0-or-later
8 + *
9 + * @wordpress-plugin
10 + * Plugin Name: Metricool - Social media and site statistics
11 + * Plugin URI: https://metricool.com/
12 + * Description: Site metrics and social media analytics for Instagram, Facebook, YouTube, LinkedIn, X Twitter. The single best tool for Social Media Managers!
13 + * Version: 2.1.1
14 + * Requires at least: 6.6
15 + * Requires PHP: 7.4
16 + * Author: Really Simple Plugins
17 + * Author URI: https://really-simple-plugins.com
18 + * License: GPL v2 or later
19 + * Text Domain: metricool
20 + * Domain Path: /assets/languages
21 + */
13 22
14 - This program is free software; you can redistribute it and/or modify
15 - it under the terms of the GNU General Public License, version 2, as
16 - published by the Free Software Foundation.
23 +if (!defined('ABSPATH')) {
24 + exit;
25 +}
17 26
18 - This program is distributed in the hope that it will be useful,
19 - but WITHOUT ANY WARRANTY; without even the implied warranty of
20 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 - GNU General Public License for more details.
27 +/**
28 + * Load the Composer autoloader for the plugin's own classes.
29 + */
30 +require_once __DIR__ . '/vendor/autoload.php';
22 31
23 - You should have received a copy of the GNU General Public License
24 - along with this program; if not, write to the Free Software
25 - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 - */
32 +/**
33 + * Load the scoped (prefixed) dependencies to prevent conflicts
34 + * with other plugins bundling the same packages.
35 + * @see https://packagist.org/packages/wpify/scoper
36 + */
37 +require_once __DIR__ . '/vendor/_scoped/scoper-autoload.php';
27 38
28 - class metricool {
29 -
30 - public $plugin;
31 -
32 - /**
33 - * Constructor
34 - */
35 - public function __construct() {
36 - // Plugin Details
37 - $this->plugin = new stdClass;
38 - $this->plugin->name = 'metricool'; // Plugin Folder
39 - $this->plugin->displayName = 'Metricool'; // Plugin Name
40 - $this->plugin->version = '1.18';
41 - $this->plugin->folder = WP_PLUGIN_DIR.'/'.$this->plugin->name; // Full Path to Plugin Folder
42 - $this->plugin->url = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
43 -
44 - // Hooks
45 - add_action('admin_init', array(&$this, 'registerSettings'));
46 - add_action('admin_menu', array(&$this, 'adminPanelsAndMetaBoxes'));
47 - add_action('admin_bar_menu', array(&$this, 'adminCustomMenu'), 1000);
48 -
49 - // Frontend Hooks
50 - add_action('wp_footer', array(&$this, 'frontendFooter'));
51 - }
52 -
53 - /**
54 - * Register Settings
55 - */
56 - function registerSettings() {
57 - register_setting($this->plugin->name, 'metricool_profile_id', 'trim');
58 - }
59 -
60 - /**
61 - * Register the plugin settings panel
62 - */
63 - function adminPanelsAndMetaBoxes() {
64 - add_submenu_page('options-general.php', $this->plugin->displayName, $this->plugin->displayName, 'manage_options', $this->plugin->name, array(&$this, 'adminPanel'));
65 - }
66 -
67 - /**
68 - * Output the Administration Panel
69 - * Save POSTed data from the Administration Panel into a WordPress option
70 - */
71 - function adminPanel()
72 - {
73 - // Save Settings
74 - if (isset($_POST['submit'])) {
75 - // Check nonce
76 - if (!isset($_POST[$this->plugin->name . '_nonce'])) {
77 - // Missing nonce
78 - $this->errorMessage = __('nonce field is missing. Settings NOT saved.', $this->plugin->name);
79 - } elseif (!wp_verify_nonce($_POST[$this->plugin->name . '_nonce'], $this->plugin->name)) {
80 - // Invalid nonce
81 - $this->errorMessage = __('Invalid nonce specified. Settings NOT saved.', $this->plugin->name);
82 - } elseif (!preg_match('/^[a-z0-9]+$/',$_POST['metricool_profile_id'])) {
83 - // Invalid nonce
84 - $this->errorMessage = __('Invalid site TOKEN. Settings NOT saved.', $this->plugin->name);
85 - }
86 - else {
87 - // Save
88 - update_option('metricool_profile_id', $_POST['metricool_profile_id']);
89 - $this->message = __('Settings Saved.', $this->plugin->name);
90 - }
91 - }
92 -
93 - // Get latest settings
94 - $this->settings = array(
95 - 'metricool_profile_id' => get_option('metricool_profile_id')
96 - );
97 -
98 - // Load Settings Form
99 - include_once(WP_PLUGIN_DIR . '/' . $this->plugin->name . '/views/settings.php');
100 - }
101 -
102 - /**
103 - * Loads plugin textdomain
104 - */
105 - function loadLanguageFiles() {
106 - load_plugin_textdomain($this->plugin->name, false, $this->plugin->name.'/languages/');
107 - }
108 -
109 - /**
110 - * Outputs script / CSS to the frontend footer
111 - */
112 - function frontendFooter() {
113 - $this->output('metricool_profile_id');
114 - }
115 -
116 - /**
117 - * Outputs the given setting, if conditions are met
118 - *
119 - * @param string $setting Setting Name
120 - * @return output
121 - */
122 - function output($setting)
123 - {
124 - // Ignore admin, feed, robots or trackbacks
125 - if (is_admin() or is_feed() or is_robots() or is_trackback()) {
126 - return;
127 - }
128 -
129 - // Get meta
130 - $meta = get_option($setting);
131 - if (empty($meta)) {
132 - return;
133 - }
134 - if (trim($meta) == '') {
135 - return;
136 - }
137 -
138 - if (!preg_match('/^[a-z0-9]+$/',$meta)) {
139 - return;
140 - }
141 -
142 - // Output
143 - echo stripslashes("<script>function loadScript(a){var b=document.getElementsByTagName(\"head\")[0],c=document.createElement(\"script\");c.type=\"text/javascript\",c.src=\"https://tracker.metricool.com/app/resources/be.js\",c.onreadystatechange=a,c.onload=a,b.appendChild(c)}loadScript(function(){beTracker.t({hash:'" . $meta . "'})})</script>");
144 - }
145 -
146 -
147 - function adminCustomMenu(){
148 - global $wp_admin_bar;
149 -
150 - if(!is_super_admin() || !is_admin_bar_showing()) return;
151 -
152 - $menu_id = "metricool_menu";
153 - $argsParent = array(
154 - "id" => $menu_id,
155 - "title" => "Metricool",
156 - "href" => "https://metricool.com/"
157 - );
158 - $wp_admin_bar->add_menu($argsParent);
159 -
160 - $argsSub1 = array(
161 - "id" => $menu_id,
162 - "parent" => $menu_id,
163 - "title" => "Evolution stats",
164 - "href" => "https://app.metricool.com/evolution",
165 - "meta" => array("target" => "_blank")
166 - );
167 - $wp_admin_bar->add_menu($argsSub1);
168 -
169 - $argsSub2 = array(
170 - "id" => $menu_id,
171 - "parent" => $menu_id,
172 - "title" => "Real time",
173 - "href" => "https://app.metricool.com/real-time",
174 - "meta" => array("target" => "_blank")
175 - );
176 - $wp_admin_bar->add_menu($argsSub2);
177 -
178 - $argsSub3 = array(
179 - "id" => $menu_id,
180 - "parent" => $menu_id,
181 - "title" => "Planner",
182 - "href" => "https://app.metricool.com/actions",
183 - "meta" => array("target" => "_blank")
184 - );
185 - $wp_admin_bar->add_menu($argsSub3);
186 -
187 - }
188 -
189 -
190 - }
191 -
192 - $metricool = new metricool();
193 -
194 - add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'metricool_add_plugin_page_settings_link');
195 - function metricool_add_plugin_page_settings_link( $links ) {
196 - $links[] = '<a href="' .
197 - admin_url( 'options-general.php?page=metricool' ) .
198 - '">' . __('Settings') . '</a>';
199 - return $links;
200 - }
39 +// Boot the plugin.
40 +$plugin = new Metricool\Bootstrap\Plugin();
41 +$plugin->boot();