PluginProbe ʕ •ᴥ•ʔ
Meta pixel for WordPress / 3.0.8
Meta pixel for WordPress v3.0.8
trunk 1.7.16 1.7.17 1.7.18 1.7.19 1.7.20 1.7.21 1.7.22 1.7.23 1.7.24 1.7.25 1.8.0 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 4.0.0 4.0.1 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 5.0.0 5.0.1 5.1.0
official-facebook-pixel / facebook-for-wordpress.php
official-facebook-pixel Last commit date
core 3 years ago css 3 years ago integration 3 years ago js 3 years ago languages 3 years ago vendor 1 year ago CODE_OF_CONDUCT.md 7 years ago CONTRIBUTING.md 7 years ago LICENSE 7 years ago changelog.txt 3 years ago composer.json 3 years ago composer.lock 3 years ago facebook-for-wordpress.php 3 years ago readme.txt 3 years ago uninstall.php 3 years ago
facebook-for-wordpress.php
103 lines
1 <?php
2 /**
3 * Plugin Name: Meta pixel for WordPress
4 * Plugin URI: https://www.facebook.com/business/help/881403525362441
5 * Description: <strong><em>***ATTENTION: After upgrade the plugin may be deactivated due to a known issue, to workaround please refresh this page and activate plugin.***</em></strong> The Facebook pixel is an analytics tool that helps you measure the effectiveness of your advertising. You can use the Facebook pixel to understand the actions people are taking on your website and reach audiences you care about.
6 * Author: Facebook
7 * Author URI: https://www.facebook.com/
8 * Version: 3.0.8
9 * Text Domain: official-facebook-pixel
10 */
11
12 /*
13 * Copyright (C) 2017-present, Facebook, Inc.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; version 2 of the License.
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.
22 */
23
24 /**
25 * @package FacebookPixelPlugin
26 */
27
28 namespace FacebookPixelPlugin;
29
30 defined('ABSPATH') or die('Direct access not allowed');
31
32 require_once plugin_dir_path(__FILE__).'vendor/autoload.php';
33
34 use FacebookPixelPlugin\Core\FacebookPixel;
35 use FacebookPixelPlugin\Core\FacebookPluginConfig;
36 use FacebookPixelPlugin\Core\FacebookPluginUtils;
37 use FacebookPixelPlugin\Core\FacebookWordpressOpenBridge;
38 use FacebookPixelPlugin\Core\FacebookWordpressOptions;
39 use FacebookPixelPlugin\Core\FacebookWordpressPixelInjection;
40 use FacebookPixelPlugin\Core\FacebookWordpressSettingsPage;
41 use FacebookPixelPlugin\Core\FacebookWordpressSettingsRecorder;
42 use FacebookPixelPlugin\Core\ServerEventAsyncTask;
43
44 class FacebookForWordpress {
45 public function __construct() {
46 // initialize options
47 FacebookWordpressOptions::initialize();
48
49 // load textdomain
50 load_plugin_textdomain(
51 FacebookPluginConfig::TEXT_DOMAIN,
52 false,
53 dirname(plugin_basename(__FILE__)) . '/languages/');
54
55 // initialize pixel
56 $options = FacebookWordpressOptions::getOptions();
57 FacebookPixel::initialize(FacebookWordpressOptions::getPixelId());
58 // Register WordPress pixel injection controlling where to fire pixel
59 add_action('init', array($this, 'registerPixelInjection'), 0);
60
61 // Listen on /events to parse pixel fired events
62 add_action('parse_request', array($this, 'handle_events_request'), 0);
63
64 // initialize admin page config
65 $this->registerSettingsPage();
66
67 // initialize the s2s event async task
68 new ServerEventAsyncTask();
69 }
70
71 /**
72 * Helper function for registering pixel injection.
73 */
74 public function registerPixelInjection() {
75 $injectionObj = new FacebookWordpressPixelInjection();
76 $injectionObj->inject();
77 }
78
79 /**
80 * Helper function for registering the settings page.
81 */
82 public function registerSettingsPage() {
83 if (is_admin()) {
84 $plugin_name = plugin_basename(__FILE__);
85 new FacebookWordpressSettingsPage($plugin_name);
86 (new FacebookWordpressSettingsRecorder())->init();
87 }
88 }
89
90 public function handle_events_request(){
91 $request_uri = $_SERVER['REQUEST_URI'];
92 if(FacebookPluginUtils::endsWith($request_uri,
93 FacebookPluginConfig::OPEN_BRIDGE_PATH)
94 && $_SERVER['REQUEST_METHOD'] == 'POST'){
95 $data = json_decode(file_get_contents('php://input'), true);
96 FacebookWordpressOpenBridge::getInstance()->handleOpenBridgeReq($data);
97 exit();
98 }
99 }
100 }
101
102 $WP_FacebookForWordpress = new FacebookForWordpress();
103