Plugin Directory

Changeset 2486582


Ignore:
Timestamp:
03/04/2021 09:22:41 AM (5 years ago)
Author:
rsukhar
Message:

Adding WooCommerce support

Location:
convertful/trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • convertful/trunk/convertful.php

    r2378652 r2486582  
    33/**
    44 * Plugin Name: Convertful - Your Ultimate On-Site Conversion Tool
    5  * Version: 2.1
     5 * Version: 2.1.1
    66 * Plugin URI: https://convertful.com/
    77 * Description: All the modern on-site conversion solutions, natively integrates with all modern Email Marketing Platforms.
    88 * Author: Convertful
     9 * Author URI: https://convertful.com
    910 * License: GPLv2 or later
    1011 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3637
    3738add_action( 'rest_api_init', function () {
    38 
    3939    register_rest_route( 'convertful/v2', '/complete_authorization/', [
    4040        'methods'  => 'POST',
    4141        'callback' => 'conv_complete_authorization',
     42        'permission_callback' => '__return_true',
    4243    ] );
    4344
     
    4546        'methods'  => 'POST',
    4647        'callback' => 'conv_get_info',
     48        'permission_callback' => '__return_true',
    4749    ] );
    4850} );
    4951
    50 /**
    51  * Get script id
    52  * @return string
    53  */
    54 function conv_get_script_id() {
    55     global $conv_config;
    56     $url = wp_parse_url( $conv_config['host'] );
    57     if ( ! preg_match( '/^(.*?)(convertful|devcf)\.[a-z]{3,5}$/', $url['host'] ) ) {
    58         return 'optin-api';
    59     }
    60 
    61     return 'convertful-api';
    62 }
    63 
    64 /**
    65  * Get script file name
    66  * @return string
    67  */
    68 function conv_get_script_filename() {
    69     return conv_get_script_id() === 'convertful-api'
    70         ? 'Convertful.js'
    71         : 'optin.js';
    72 }
    73 
    74 
    75 function conv_init() {
     52function conv_init()  {
     53    global $conv_dir;
     54
    7655    if ( get_option( 'optinguru_owner_id' ) ) {
    7756        update_option( 'conv_owner_id', get_option( 'optinguru_owner_id' ), TRUE );
     
    9271        add_filter( 'the_content', 'conv_after_post_content' );
    9372    }
     73
     74    if (function_exists( 'woocommerce_get_page_id' ))
     75    {
     76        require $conv_dir . 'functions/woocommerce.php';
     77    }
     78}
     79/**
     80 * Get script id
     81 * @return string
     82 */
     83function conv_get_script_id() {
     84    global $conv_config;
     85    $url = wp_parse_url( $conv_config['host'] );
     86    if ( ! preg_match( '/^(.*?)(convertful|devcf)\.[a-z]{3,5}$/', $url['host'] ) ) {
     87        return 'optin-api';
     88    }
     89
     90    return 'convertful-api';
     91}
     92
     93/**
     94 * Get script file name
     95 * @return string
     96 */
     97function conv_get_script_filename() {
     98    return conv_get_script_id() === 'convertful-api'
     99        ? 'Convertful.js'
     100        : 'optin.js';
    94101}
    95102
     
    121128        'categories' => $categories,
    122129        'tags'       => $tags,
     130        'ajax_url'   => get_home_url() . '/index.php?rest_route=/convertful/v2/' ,
    123131        'userRoles'  => ( $user_meta instanceof WP_User and ! empty( $user_meta->roles ) ) ? $user_meta->roles : [ 'guest' ],
    124132    ] );
     
    149157}
    150158
    151 function conv_complete_authorization( WP_REST_Request $request ) {
     159function conv_complete_authorization( $request ) {
    152160    $owner_id     = (int) $request->get_param( 'owner_id' );
    153161    $site_id      = (int) $request->get_param( 'site_id' );
     
    205213    ];
    206214
     215    if (function_exists( 'woocommerce_get_page_id' )){
     216        // Add WooCommerce coupons and products
     217        $result['woo_coupons'] = get_woo_coupons();
     218        $result['woo_products'] = get_woo_products();
     219        $result['woo_enabled'] = TRUE;
     220    }
     221
    207222    wp_send_json_success( $result );
    208223}
  • convertful/trunk/readme.txt

    r2378652 r2486582  
    33Tags: optin, opt-in, mailchimp, popup, bar, slidein, subscribe, signup, form, email, marketing, lead, campaign
    44Requires at least: 4.0
    5 Tested up to: 5.5.1
     5Tested up to: 5.6.2
    66Stable tag: 2.1
    77License: GPLv2 or later
     
    102102== Changelog ==
    103103
     104= 2.2 =
     105* Add WooCommerce functionality
     106
    104107= 2.1 =
    105108* Bug fixes
Note: See TracChangeset for help on using the changeset viewer.