PluginProbe
Convertful – Your Ultimate On-Site Conversion Tool / 1.1
Convertful – Your Ultimate On-Site Conversion Tool v1.1
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.1, at convertful.php

119 lines 4.0 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.2
6 * Plugin URI: https://convertful.com/
7 * Description: Acquire leads using smart targeted sign-up forms. Works with MailChimp and all other major email services
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_conv-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 return;
75 }
76 // Taking into account promotional links
77 $ref_data = get_transient( 'convertful-ref' );
78 if ( $ref_data AND strpos( $ref_data, '|' ) !== FALSE ) {
79 $ref_data = explode( '|', $ref_data );
80 // Preventing violations with lifetime values
81 if ( time() - intval( $ref_data[1] ) < DAY_IN_SECONDS ) {
82 update_option( 'convertful_ref', $ref_data[0], FALSE );
83 }
84 delete_transient( 'convertful-ref' );
85 }
86 $owner_id = get_option( 'convertful_owner_id' );
87 if ( $owner_id === FALSE ) {
88 $redirect_location = admin_url( 'tools.php?page=conv-settings' );
89 if ( wp_doing_ajax() ) {
90 wp_send_json_success(
91 array(
92 'location' => $redirect_location,
93 )
94 );
95 }
96 wp_redirect( $redirect_location );
97 exit;
98 }
99 }
100
101 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'conv_plugin_action_links' );
102 function conv_plugin_action_links( $links ) {
103 return array_merge(
104 array(
105 '<a href="' . admin_url( 'tools.php?page=conv-settings' ) . '">' . __( 'Settings' ) . '</a>',
106 ), $links
107 );
108 }
109
110
111 register_uninstall_hook( $conv_file, 'conv_uninstall' );
112 function conv_uninstall() {
113 // Options cleanup
114 foreach ( array( 'owner_id', 'site_id', 'website_id', 'token', 'ref' ) as $option_name ) {
115 delete_option( 'optinguru_' . $option_name );
116 delete_option( 'convertful_' . $option_name );
117 }
118 }
119