PluginProbe
LeadConnector / 4.0.3
LeadConnector v4.0.3
4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.0.34 3.0.33 trunk 0.1.0 0.2.0 0.3.0 0.4.0 0.5.0 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 All 68 releases
leadconnector / leadconnector.php

leadconnector.php in LeadConnector 4.0.3, at leadconnector.php

179 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 * The plugin bootstrap file
5 *
6 * This file is read by WordPress to generate the plugin information in the plugin
7 * admin area. This file also includes all of the dependencies used by the plugin,
8 * registers the activation and deactivation functions, and defines a function
9 * that starts the plugin.
10 *
11 * @link https://www.leadconnectorhq.com
12 * @since 1.0.0
13 * @package LeadConnector
14 *
15 * @wordpress-plugin
16 * Plugin Name: LeadConnector
17 * Plugin URI: https://www.leadconnectorhq.com/
18 * Description: This plugin helps you to add the lead connector widgets to your website.
19 * Version: 4.0.3
20 * Requires at least: 6.2
21 * Requires PHP: 7.4
22 * Author: LeadConnector
23 * Author URI: https://www.leadconnectorhq.com
24 * License: GPL-3.0+
25 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
26 * Text Domain: leadconnector
27 * Domain Path: /languages
28 */
29
30 // If this file is called directly, abort.
31 if ( ! defined( 'ABSPATH' ) ) {
32 exit;
33 }
34
35 /**
36 * Currently plugin version.
37 * Start at version 1.0.0 and use SemVer - https://semver.org
38 * Rename this for your plugin and update it as you release new versions.
39 */
40
41 if ( file_exists( __DIR__ . '/config.php' ) ) {
42 require_once __DIR__ . '/config.php';
43 } else {
44 wp_die(
45 esc_html__( 'LeadConnector: config.php is missing. Please re-install the plugin.', 'leadconnector' )
46 );
47 }
48
49 // Constants That are required by plugin that are not part of the default config.php.
50 define( 'LEAD_CONNECTOR_OAUTH_CALLBACK_URL', get_option( 'siteurl', '__missing_siteurl__' ) );
51
52
53 /**
54 * Add custom query variables to WordPress.
55 *
56 * @param array $vars Existing query variables.
57 * @return array
58 */
59 function leadconnector_register_query_vars( $vars ) {
60 $vars[] = 'leadconnector_token';
61 $vars[] = 'elementor_highlight';
62 return $vars;
63 }
64 add_filter( 'query_vars', 'leadconnector_register_query_vars' );
65
66 /**
67 * The code that runs during plugin activation.
68 * This action is documented in includes/class-leadconnector-activator.php
69 */
70 function leadconnector_activate() {
71 require_once plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector-constants.php';
72 require_once plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector-activator.php';
73 LeadConnector_Activator::activate();
74
75 leadconnector_register_query_vars( array() );
76 flush_rewrite_rules();
77 }
78
79 /**
80 * The code that runs during plugin deactivation.
81 * This action is documented in includes/class-leadconnector-deactivator.php
82 */
83 function leadconnector_deactivate() {
84 require_once plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector-deactivator.php';
85 LeadConnector_Deactivator::deactivate();
86
87 flush_rewrite_rules();
88 }
89
90 register_activation_hook( __FILE__, 'leadconnector_activate' );
91 register_deactivation_hook( __FILE__, 'leadconnector_deactivate' );
92
93 /**
94 * The core plugin class that is used to define internationalization,
95 * admin-specific hooks, and public-facing site hooks.
96 */
97 require plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector.php';
98 require plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector-update-functions.php';
99 require plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector-ai-page-preview.php';
100
101 // Add Elementor CLI.
102 require plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector-elementor-cli.php';
103 require plugin_dir_path( __FILE__ ) . 'includes/class-leadconnector-preview-cli.php';
104 require plugin_dir_path( __FILE__ ) . 'includes/SeoOverrides/class-leadconnector-seo-overrides.php';
105
106 /**
107 * Begins execution of the plugin.
108 *
109 * Since everything within the plugin is registered via hooks,
110 * then kicking off the plugin from this point in the file does
111 * not affect the page life cycle.
112 *
113 * @since 1.0.0
114 */
115 function leadconnector_run() {
116 $plugin = new LeadConnector();
117 $plugin->run();
118 }
119 leadconnector_run();
120
121
122 // M8: uninstall.php is the authoritative uninstall handler; register_uninstall_hook()
123 // is superseded when uninstall.php exists and has been removed to avoid duplication.
124
125 /**
126 * Enqueue Elementor CSS overrides for pages built with Elementor.
127 *
128 * @return void
129 */
130 function leadconnector_enqueue_elementor_overrides() {
131 if ( ! did_action( 'elementor/loaded' ) && ! class_exists( '\Elementor\Plugin' ) ) {
132 return;
133 }
134
135 $post_id = get_the_ID();
136 if ( ! $post_id || ! get_post_meta( $post_id, '_elementor_edit_mode', true ) ) {
137 return;
138 }
139
140 wp_register_style(
141 'leadconnector-elementor-overrides',
142 plugin_dir_url( __FILE__ ) . 'public/css/custom-elementor.css',
143 array(),
144 '1.0.0'
145 );
146
147 wp_enqueue_style( 'leadconnector-elementor-overrides' );
148 }
149 add_action( 'wp_enqueue_scripts', 'leadconnector_enqueue_elementor_overrides' );
150
151 /**
152 * Load theme fixes CSS on all frontend pages
153 * Fixes responsive header padding for block themes
154 */
155 function leadconnector_enqueue_theme_fixes() {
156 // L4: Only enqueue on pages that actually display LeadConnector funnel/page content.
157 // Loading this CSS unconditionally adds a network request to every frontend page,
158 // including posts and archives that have nothing to do with LC. We check for an
159 // LC funnel step URL stored in the current post's meta as the gate.
160 if ( ! is_singular() ) {
161 return;
162 }
163 $post_id = get_the_ID();
164 if ( ! $post_id || ! get_post_meta( $post_id, 'leadconnector_step_url', true ) ) {
165 return;
166 }
167
168 $css_file = plugin_dir_path( __FILE__ ) . 'public/css/theme-fixes.css';
169 $version = file_exists( $css_file ) ? filemtime( $css_file ) : LEAD_CONNECTOR_VERSION;
170
171 wp_enqueue_style(
172 'leadconnector-theme-fixes',
173 plugin_dir_url( __FILE__ ) . 'public/css/theme-fixes.css',
174 array(),
175 $version
176 );
177 }
178 add_action( 'wp_enqueue_scripts', 'leadconnector_enqueue_theme_fixes' );
179