PluginProbe
Convertful – Your Ultimate On-Site Conversion Tool / 1.0
Convertful – Your Ultimate On-Site Conversion Tool v1.0
trunk 1.0 1.1 1.3 1.4 1.5 1.6 1.7 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8
convertful / convertful.php

convertful.php in Convertful – Your Ultimate On-Site Conversion Tool 1.0, at convertful.php

99 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php defined( 'ABSPATH' ) OR die( 'This script cannot be accessed directly.' );
2
3 /**
4 * Plugin Name: Convertful MailChimp Forms
5 * Version: 1.0
6 * Plugin URI: https://convertful.com/
7 * Description: Convert visitors to subscribers with targeted pop-ups, sideboxes, bars and inlines. Works not only with MailChimp
8 * Author: Convertful
9 * License: GPLv2 or later
10 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11 * Text Domain: convertful
12 */
13
14 // Global variables for plugin usage (global declaration is needed here for WP CLI compatibility)
15 global $conv_file, $conv_dir, $conv_uri, $conv_version, $conv_domain;
16 //$conv_domain = 'http://convertful.local';
17 $conv_domain = 'https://app.convertful.com';
18 $conv_file = __FILE__;
19 $conv_dir = plugin_dir_path( __FILE__ );
20 $conv_uri = plugins_url( '', __FILE__ );
21 $conv_version = preg_match( '~Version\: ([^\n]+)~', file_get_contents( __FILE__, NULL, NULL, 82, 150 ), $conv_matches ) ? $conv_matches[1] : FALSE;
22 unset( $conv_matches );
23
24 add_action( 'init', 'conv_init' );
25 function conv_init() {
26 if ( get_option( 'optinguru_owner_id' ) ) {
27 update_option( 'convertful_owner_id', get_option( 'optinguru_owner_id' ), TRUE );
28 update_option( 'convertful_site_id', get_option( 'optinguru_site_id', get_option( 'optinguru_website_id' ) ), FALSE );
29 update_option( 'convertful_token', get_option( 'optinguru_token' ), FALSE );
30 }
31 $owner_id = get_option( 'convertful_owner_id' );
32 if ( ! is_admin() AND $owner_id !== FALSE ) {
33 add_action( 'wp_enqueue_scripts', 'conv_enqueue_scripts' );
34 add_filter( 'script_loader_tag', 'conv_script_loader_tag', 10, 2 );
35 }
36 }
37
38 if ( is_admin() ) {
39 require $conv_dir . 'functions/admin_pages.php';
40 }
41
42 // Shortcodes
43 require $conv_dir . 'functions/shortcodes.php';
44
45 function conv_enqueue_scripts() {
46 global $conv_domain, $conv_version;
47 wp_enqueue_script( 'convertful-api', $conv_domain . '/Convertful.js', array(), $conv_version, TRUE );
48 }
49
50 function conv_script_loader_tag( $tag, $handle ) {
51 if ( $handle !== 'convertful-api' ) {
52 return $tag;
53 }
54 global $conv_domain;
55
56 return '<script type="text/javascript" id="convertful-api" src="' . $conv_domain . '/Convertful.js" data-owner="' . get_option( 'convertful_owner_id' ) . '" async="async"></script>';
57 }
58
59 add_action( 'admin_enqueue_scripts', 'conv_admin_enqueue_scripts' );
60 function conv_admin_enqueue_scripts( $hook ) {
61 if ( $hook !== 'tools_page_og-settings' ) {
62 return;
63 }
64
65 global $conv_uri, $conv_version;
66 wp_enqueue_style( 'conv-main', $conv_uri . '/css/main.css', array(), $conv_version );
67 wp_enqueue_script( 'conv-main', $conv_uri . '/js/main.js', array( 'jquery' ), $conv_version );
68 }
69
70 add_action( 'activated_plugin', 'conv_activated_plugin' );
71 function conv_activated_plugin( $plugin ) {
72 global $conv_file;
73 if ( $plugin === plugin_basename( $conv_file ) ) {
74 $owner_id = get_option( 'convertful_owner_id' );
75 if ( $owner_id === FALSE ) {
76 wp_redirect( admin_url( 'tools.php?page=og-settings' ) );
77 exit;
78 }
79 }
80 }
81
82 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'conv_plugin_action_links' );
83 function conv_plugin_action_links( $links ) {
84 return array_merge(
85 array(
86 '<a href="' . admin_url( 'tools.php?page=og-settings' ) . '">' . __( 'Settings' ) . '</a>',
87 ), $links
88 );
89 }
90
91
92 register_uninstall_hook( $conv_file, 'conv_uninstall' );
93 function conv_uninstall() {
94 // Options cleanup
95 foreach ( array( 'owner_id', 'site_id', 'website_id', 'token' ) as $option_name ) {
96 delete_option( 'optinguru_' . $option_name );
97 delete_option( 'convertful_' . $option_name );
98 }
99 }