<commit_before><?php
/**
 * Plugin Name: OCTI.io for seller
 * Plugin URI: http://www.octi.io
 * Description: Integration plugin for theme sellers at octi.io.
 * Version: 1.0.1
 * Author: OCTI.io
 * Author URI: http://www.octi.io
 * Requires at least: 4.3
 * Tested up to: 4.3
 *
 * Text Domain: octi-for-seller
 * Domain Path: /i18n/languages/
 *
 * @package OCTI_FOR_SELLER
 * @category Core
 * @author OCTI
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

if (!defined('OCTI_BASE_URL')) {
    define('OCTI_BASE_URL', 'https://www.octi.io/shop');
}


/**
 * Main class
 *
 * @class OCTI_FOR_SELLER
 * @version 1.0
 */
final class OCTI_FOR_SELLER {

    public function __construct() {
        add_action('init', array($this, 'init'));
        add_action('admin_init', array($this, 'admin_init'));
        add_action('parse_request', array($this, 'octi_install') );
    }

    /**
     * Static function to build the internal link
     * use like OCTI_FOR_SELLER::link('hola')
     * @version 1.0
     * @return string http link
     */
    public static function link($name) {
        return self::get_internal_link($name);
    }

    /**
     * Static function to build the button with internal link
     * use like OCTI_FOR_SELLER::button('hola')
     * @version 1.0
     * @return string html link
     */
    public static function button($name, $args) {
        return self::get_octi_button($args, self::get_internal_link($name));
    }

    /**
     * Detect on request parsing the octi button and redirect to octi.io
     * @version 1.0
     */
    public function octi_install() {
        global $wp;

        if (!isset($_GET['octi']) || !isset($_GET['name'])) return;
        if (!preg_match('/[a-z0-9\-]+/i', $_GET['name'])) return;
        if (!wp_verify_nonce($_GET['nonce'], 'octi-install-'.$_GET['name'] )) return;

        if (!isset($this->settings)) {
            $this->settings = (array) get_option( 'octi-for-seller' );
        }

        header('Location: '.OCTI_OTP::generate( $this->settings['key'], $_GET['name'] ));
        exit();
    }

    /**
     * General functions
     * @version 1.0
     */
    public function init() {
        add_shortcode('octi-button', array($this, 'shortcode_octi_button') );
        add_shortcode('octi-link', array($this, 'shortcode_octi_link') );
        add_shortcode('octi_button', array($this, 'shortcode_octi_button') );
        add_shortcode('octi_link', array($this, 'shortcode_octi_link') );
        add_filter('woocommerce_available_download_link', array($this, 'woocommerce_available_download_link'), 1, 2);
        add_action('woocommerce_order_item_meta_end', array($this, 'woocommerce_order_item_meta_end'), 5, 3 );
    }

    /**
     * WooCommerce Basic integration
     * Show botton in the "available downloads" list. Next to each download link
     * @version 1.0
     */
    public function woocommerce_available_download_link($html, $download) {

        $name = get_post_meta($download['product_id'],'octi_name', true);

        // This product don't has the octi_name meta
        if (empty($name)) return $html;<commit_msg>Redirect to my-account in case nonce or session are expired<commit_after><?php
/**
 * Plugin Name: OCTI.io for seller
 * Plugin URI: http://www.octi.io
 * Description: Integration plugin for theme sellers at octi.io.
 * Version: 1.0.1
 * Author: OCTI.io
 * Author URI: http://www.octi.io
 * Requires at least: 4.3
 * Tested up to: 4.3
 *
 * Text Domain: octi-for-seller
 * Domain Path: /i18n/languages/
 *
 * @package OCTI_FOR_SELLER
 * @category Core
 * @author OCTI
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

if (!defined('OCTI_BASE_URL')) {
    define('OCTI_BASE_URL', 'https://www.octi.io/shop');
}


/**
 * Main class
 *
 * @class OCTI_FOR_SELLER
 * @version 1.0
 */
final class OCTI_FOR_SELLER {

    public function __construct() {
        add_action('init', array($this, 'init'));
        add_action('admin_init', array($this, 'admin_init'));
        add_action('parse_request', array($this, 'octi_install') );
    }

    /**
     * Static function to build the internal link
     * use like OCTI_FOR_SELLER::link('hola')
     * @version 1.0
     * @return string http link
     */
    public static function link($name) {
        return self::get_internal_link($name);
    }

    /**
     * Static function to build the button with internal link
     * use like OCTI_FOR_SELLER::button('hola')
     * @version 1.0
     * @return string html link
     */
    public static function button($name, $args) {
        return self::get_octi_button($args, self::get_internal_link($name));
    }

    /**
     * Detect on request parsing the octi button and redirect to octi.io
     * @version 1.0
     */
    public function octi_install() {
        global $wp;

        if (!isset($_GET['octi']) || !isset($_GET['name'])) return;
        if (!preg_match('/[a-z0-9\-]+/i', $_GET['name'])) return;
        if (!isset($this->settings)) {
            $this->settings = (array) get_option( 'octi-for-seller' );
        }

        if (!wp_verify_nonce($_GET['nonce'], 'octi-install-'.$_GET['name'] )) {
            header('Location: '.get_permalink( get_option('woocommerce_myaccount_page_id') ).'?octi=afterlogin&slug='.$_GET['name']);
            exit();
        }


        header('Location: '.OCTI_OTP::generate( $this->settings['key'], $_GET['name'] ));
        exit();
    }

    /**
     * General functions
     * @version 1.0
     */
    public function init() {
        add_shortcode('octi-button', array($this, 'shortcode_octi_button') );
        add_shortcode('octi-link', array($this, 'shortcode_octi_link') );
        add_shortcode('octi_button', array($this, 'shortcode_octi_button') );
        add_shortcode('octi_link', array($this, 'shortcode_octi_link') );
        add_filter('woocommerce_available_download_link', array($this, 'woocommerce_available_download_link'), 1, 2);
        add_action('woocommerce_order_item_meta_end', array($this, 'woocommerce_order_item_meta_end'), 5, 3 );
    }

    /**
     * WooCommerce Basic integration
     * Show botton in the "available downloads" list. Next to each download link
     * @version 1.0
     */
    public function woocommerce_available_download_link($html, $download) {

        $name = get_post_meta($download['product_id'],'octi_name', true);

        // This product don't has the octi_name meta
        if (empty($name)) return $html;
{'fraction_non_alphanumeric': 0.15326439265318723, 'fraction_numerical': 0.008334619540052476, 'mean_word_length': 3.0273461777501556, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1969910', 'n_tokens_mistral': 2202, 'n_tokens_neox': 2102, 'n_words': 472}