define_constants();
$this->hooks();
do_action( 'pqc_loaded' );
}
/**
* Define constant if not already set.
*
* @param string $name
* @param string|bool $value
* @since 1.6
*/
private function define( $name, $value )
{
if ( ! defined( $name ) ) define( $name, $value );
}
/**
* Define PQC Constants.
*/
private function define_constants()
{
require_once( ABSPATH.'wp-admin/includes/plugin.php' );
global $wpdb;
$plugin_data = get_plugin_data( __FILE__ );
$this->define( 'PQC_URL', plugin_dir_url( __FILE__ ) );
$this->define( 'PQC_PATH', plugin_dir_path( __FILE__ ) );
$this->define( 'PQC_PLUGIN', plugin_basename( __FILE__ ) );
$this->define( 'PQC_NAME', $plugin_data['Name'] );
$this->define( 'PQC_VERSION', $plugin_data['Version'] );
$this->define( 'PQC_AUTHOR', $plugin_data['Author'] );
$this->define( 'PQC_AUTHOR_URI', $plugin_data['AuthorURI'] );
$this->define( 'PQC_PHANES_API_URI', 'https://phanes.co/' );
$this->define( 'PQC_API_PHANES_URI', 'https://api.phanes.co/' );
$this->define( 'PQC_SETTING_PAGE', 'admin.php?page=pqc-settings-page' );
$this->define( 'PQC_SETTING_OPTIONS', 'pqc-options' );
$this->define( 'PQC_MATERIALS_TABLE', $wpdb->prefix . 'pqc_materials' );
$this->define( 'PQC_ORDERS_TABLE', $wpdb->prefix . 'pqc_orders' );
$this->define( 'PQC_DATA_TABLE', $wpdb->prefix . 'pqc_data' );
$this->define( 'PQC_UPLOAD_SHORTCODE', 'pqc_upload' );
$this->define( 'PQC_CART_SHORTCODE', 'pqc_cart' );
$this->define( 'PQC_CHECKOUT_SHORTCODE', 'pqc_checkout' );
$this->define( 'PQC_ORDERS_SHORTCODE', 'pqc_orders' );
$this->define( 'PQC_CONTENT_DIR', WP_CONTENT_DIR . "/uploads/pqc/" );
$this->define( 'PQC_CONTENT_URL', WP_CONTENT_URL . "/uploads/pqc/" );
$this->define( 'PQC_REQUIRES_WP', '4.1' );
}
/**
* Hook into actions and filters.
* @since 1.6
*/
private function hooks()
{
add_action( 'init', array( $this, 'plugin_check' ), 1);
add_action( 'init', array( $this, 'init' ), 1);
add_action( 'plugins_loaded', array( $this, 'i18n' ), 0 );
add_filter( "plugin_action_links_" . PQC_PLUGIN, array( $this, 'plugin_links' ) );
add_action( 'wp_head', array( $this, 'js_detection' ), 0 );
add_filter( 'query_vars', array( $this, 'add_query_vars' ) );
add_filter( 'rewrite_rules_array', array( $this, 'add_rewrite_rules' ) );
}
/**
* Check Plugin Requirements
* @since 1.0
*/
public function plugin_check()
{
if ( ! version_compare( $GLOBALS['wp_version'], PQC_REQUIRES_WP, '>=' ) ) {
$this->add_notice(
sprintf(
__( '%s plugin requires a
newer version
of WordPress to work properly.', 'pqc'
),
PQC_NAME
), 'error', false
);
$this->plugin_inactive = true;
}
if ( version_compare( get_option( 'pqc-version' ), PQC_VERSION, '<' ) )
$this->run_setup();
if (
! get_option( PQC_SETTING_OPTIONS, false ) ||
! $this->table_exist( PQC_DATA_TABLE ) ||
! $this->table_exist( PQC_MATERIALS_TABLE )
) {
if (
get_option( 'pqc-version', 'not exist' ) == 'not exist' ||
get_option( 'pqc-version' ) != PQC_VERSION
) {
if ( is_admin() && current_user_can( 'manage_options' ) ) $this->run_setup();
$this->plugin_inactive = false;
} else {
$notice = $this->add_notice(
sprintf(
__( '%s needs some setup.
Run setup', 'pqc'
),
PQC_NAME,
add_query_arg( 'pqc-setup', 'setup' )
), 'error', false
);
$this->plugin_inactive = true;
}
}
}
/**
* Initialize the plugin
* @since 1.0
*/
public function init()
{
// Before init action.
do_action( 'before_pqc_init' );
// Init check
$this->init_check();
// Load GLOBAL Variables
$this->globals();
// Add Default Materials, if no material
$this->insert_default_materials();
// Remove Expired Files if we have any
$this->remove_expired_files();
// Include/Require Files
$this->includes();
// Init action.
do_action( 'pqc_init' );
}
/**
* Do the Init method check
* @since 1.6
*
*/
private function init_check()
{
if (
isset( $_REQUEST['pqc-setup'] ) &&
$_REQUEST['pqc-setup'] == 'setup' &&
is_admin() &&
current_user_can( 'manage_options' )
) { $this->run_setup(); }
if ( $this->plugin_inactive ) return;
if (
isset( $_REQUEST['pqc-setup'] ) &&
$_REQUEST['pqc-setup'] == 'complete' &&
is_admin() &&
current_user_can( 'manage_options' )
) {
$this->add_notice(
sprintf(
__( 'Thank you for using %s.
Setup is complete.', 'pqc'
),
PQC_NAME
), 'updated pqc-inner-notice'
);
}
}
/**
* PQC GLOBAL Variables
* @since 1.1.1
*/
private function globals()
{
$sections = array(
'checkout_options' => array(
'label' => 'Checkout Options',
'callback' => array( 'PQC_Admin', 'checkout_section' ),
),
'paypal' => array(
'label' => 'PayPal',
'callback' => array( 'PQC_Admin', 'paypal_section' ),
),
'stripe' => array(
'label' => 'Stripe',
'callback' => array( 'PQC_Admin', 'stripe_section' ),
),
);
$payment_options = array();
if ( pqc_is_paypal_ready( true ) ) {
$payment_options['paypal'] = array(
'label' => 'PayPal
',
'callback' => array(
'url' => PQC_PATH . 'core/paypal.php',
'start' => array( 'PQC_PayPal', 'payment_start' ),
'end' => array( 'PQC_PayPal', 'payment_end' )
),
'desc' => __( 'Pay via PayPal; you can pay with your credit card if you don’t have a PayPal account.', 'pqc' ),
);
}
if ( pqc_is_stripe_ready( true ) ) {
$payment_options['stripe'] = array(
'label' => 'Stripe
',
'callback' => array(
'url' => PQC_PATH . 'core/stripe.php',
'start' => array( 'PQC_Stripe', 'payment_start' ),
'end' => array( 'PQC_Stripe', 'payment_end' )
),
'desc' => __( 'Pay via Stripe; Pay with your credit card.', 'pqc' ),
);
}
$tabs = array(
// General Tab
'general' => array(
'label' => __( 'General', 'pqc' ),
'callback' => array( 'PQC_Admin', 'general_tab' ),
),
// Checkout Tab
'checkout' => array(
'label' => __( 'Checkout', 'pqc' ),
'callback' => array( 'PQC_Admin', 'checkout_section' ),
'sections' => $sections + apply_filters( 'pqc_checkout_settings_sections', array() ),
),
// AstroPrint Tab
'astroprint' => array(
'label' => __( 'AstroPrint', 'pqc' ),
'callback' => array( 'PQC_Admin', 'astroprint_tab' )
),
);
$GLOBALS['pqc_settings_tabs'] = $tabs + apply_filters( 'pqc_settings_tabs', array() );
$GLOBALS['pqc_payment_options'] = $payment_options + apply_filters( 'pqc_payment_options', array() );
$GLOBALS['pqc_getting_started_tabs'] = array(
'start' => __( 'Getting Started', 'pqc' ),
'about' => __( 'About', 'pqc' ),
);
}
/**
* Loads reqiured files
* @since 1.6
*/
protected function includes()
{
require_once PQC_PATH . 'core/admin.php';
if ( $this->plugin_inactive ) return;
require_once PQC_PATH . 'core/public.php';
}
/**
* Add query vars
* @since 1.0
* @param mixed $args
*/
public function add_query_vars( $args )
{
array_push( $args, 'order_id', 'order_status', 'payment_method'/*, 'order_action'*/ );
$flush = get_option( 'pqc-rewrite-flush' );
if ( $flush != 1 ) {
$this->flush_rewrite_rules();
update_option( 'pqc-rewrite-flush', 1 );
}
return $args;
}
/**
* Add rewrite rules
* @since 1.0
* @param mixed $rules
*/
public function add_rewrite_rules( $rules )
{
$new_rules = array(
'pqc-checkout/(processing|complete)/([a-z]+)/?$' => 'index.php?pagename=pqc-checkout&order_status=$matches[1]&payment_method=$matches[2]',
// 'pqc-orders/(view-order)/([0-9]+)/?$' => 'index.php?pagename=pqc-orders&order_action=$matches[1]&order_id=$matches[2]',
);
$rules = $new_rules + $rules;
return $rules;
}
/**
* Add Notice
* @since 1.0
* @param mixed $msg The message to display
* @param mixed $class The css class of notice, Accepts "updated and error".
*/
public function add_notice( $msg, $class, $dismiss = true, $echo = false )
{
if ( ! is_admin() ) return;
$dismiss = ( $dismiss === true ) ?
'' : '';
$notice = '
' . $msg . '
' . $dismiss . '
';
if ( $echo === true )
echo $notice;
else
self::$_notice .= $notice;
}
/**
* Prepare/Set the default PQC option
* @since 1.0
*/
private function prepare_options()
{
$options = maybe_unserialize( get_option( PQC_SETTING_OPTIONS, false ) );
$pqc_general_settings = array(
'max_file_size' => 50,
'max_file_stay' => 3,
'max_file_upload' => 10,
'min_file_volume' => 1,
'initial_price' => 1.00,
'currency' => 'USD',
'currency_pos' => 'left',
'density_charge' => 0,
);
$pqc_checkout_settings = array(
'shop_location' => 1,
'checkout_option' => 1,
'paypal_active' => 1,
'paypal_client_id' => '',
'paypal_client_secret_key' => '',
'paypal_email' => get_bloginfo( 'admin_email' ),
'paypal_sandbox' => 0,
'stripe_active' => 1,
'stripe_secret_key' => '',
'stripe_publishable_key' => '',
);
$pqc_astroprint_settings = array(
'folder_id' => '',
'folder_name' => uniqid('PH3DP_'),
'request_token' => '',
);
if ( ! $options ) {
$data = array(
'pqc_general_settings' => $pqc_general_settings,
'pqc_checkout_settings' => $pqc_checkout_settings,
'pqc_astroprint_settings' => $pqc_astroprint_settings,
);
update_option( PQC_SETTING_OPTIONS, $data );
} else {
if (
! isset( $options['pqc_astroprint_settings'] ) ||
empty( $options['pqc_astroprint_settings'] )
) {
$data = array(
'pqc_general_settings' => wp_parse_args(
$options['pqc_general_settings'],
$pqc_general_settings
),
'pqc_checkout_settings' => wp_parse_args(
$options['pqc_checkout_settings'],
$pqc_checkout_settings
),
'pqc_astroprint_settings' => wp_parse_args(
$options['pqc_astroprint_settings'],
$pqc_astroprint_settings
),
);
update_option( PQC_SETTING_OPTIONS, $data );
}
$count_generals = count( $options['pqc_general_settings'] );
$count_checkout = count( $options['pqc_checkout_settings'] );
$count_astroprint = count( $options['pqc_astroprint_settings'] );
if (
$count_generals < count( $pqc_general_settings ) ||
$count_checkout < count( $pqc_checkout_settings ) ||
$count_astroprint < count( $pqc_astroprint_settings )
) {
$data = array(
'pqc_general_settings' => wp_parse_args(
$options['pqc_general_settings'],
$pqc_general_settings
),
'pqc_checkout_settings' => wp_parse_args(
$options['pqc_checkout_settings'],
$pqc_checkout_settings
),
'pqc_astroprint_settings' => wp_parse_args(
$options['pqc_astroprint_settings'],
$pqc_astroprint_settings
),
);
update_option( PQC_SETTING_OPTIONS, $data );
}
}
update_option( 'pqc-rewrite-flush', 0 );
}
/**
* Add default pages
* @since 1.0
*/
private function add_default_pages()
{
$pages = array(
'upload' => array( 'Upload', PQC_UPLOAD_SHORTCODE ),
'cart' => array( 'Cart', PQC_CART_SHORTCODE ),
'checkout' => array( 'Checkout', PQC_CHECKOUT_SHORTCODE ),
'orders' => array( 'Orders', PQC_ORDERS_SHORTCODE ),
);
// Create pages
foreach( $pages as $name => $args ) {
$name = 'pqc-' . sanitize_title( $name );
if ( pqc_page_exists( $name ) !== 0 ) continue;
$args = array(
'post_content' => '[' . $args[1] . ']',
'post_title' => $args[0],
'post_name' => $name,
'post_status' => 'publish',
'post_type' => 'page',
'comment_status' => 'closed',
);
wp_insert_post( $args );
}
}
/**
* Perform database table setup
* @since 1.0
*/
private function setup_db_tables()
{
global $wpdb;
$current_time = current_time( 'mysql' );
$table1 = PQC_DATA_TABLE;
$table2 = PQC_MATERIALS_TABLE;
$queries[] = "CREATE TABLE IF NOT EXISTS $table1 (
ID bigint(255) unsigned NOT NULL AUTO_INCREMENT,
unique_id varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
item_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
item_data longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
user_ip varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
status varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
date_created datetime NOT NULL DEFAULT '$current_time',
expiry_date datetime NOT NULL DEFAULT '$current_time',
PRIMARY KEY (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;";
$queries[] = "CREATE TABLE IF NOT EXISTS $table2 (
ID bigint(255) unsigned NOT NULL AUTO_INCREMENT,
author bigint(255) unsigned NOT NULL,
material_name varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
material_description longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
material_cost longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
material_density longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
date_created datetime NOT NULL DEFAULT '$current_time',
date_modified datetime NOT NULL DEFAULT '$current_time',
PRIMARY KEY (ID)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;";
// Remove order table data if exist for this version of pqc
if ( $this->table_exist( PQC_ORDERS_TABLE ) ) {
$this->move_orders();
$queries[] = "DROP TABLE " . PQC_ORDERS_TABLE;
}
// Check if column doesnot exist for old version data table
if (
$this->table_exist( $table1 ) == 1 &&
$this->column_exist( $table1, 'status' ) == 0
) {
$queries[] = "ALTER TABLE $table1
ADD `status` VARCHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending'
AFTER `user_ip`;";
}
// Check if column doesnot exist for old version materials table
if (
$this->table_exist( $table2 ) == 1 &&
$this->column_exist( $table2, 'material_density' ) == 0
) {
$queries[] = "ALTER TABLE $table2
ADD `material_density` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL AFTER `material_cost`;";
}
foreach ( $queries as $query ) {
$result = $wpdb->query( $query );
if ( ! $result ) {
$this->add_notice( sprintf(
__( '%s failed to run correctly. Please, contact the Developer.', 'pqc' ),
PQC_NAME, PQC_AUTHOR_URI )
);
$this->plugin_inactive = true;
break;
}
}
}
/**
* Move Order Table Data
*
*/
public function move_orders()
{
global $wpdb;
$orders = $wpdb->get_results( "SELECT * FROM " . PQC_ORDERS_TABLE );
if ( ! $orders || empty( $orders ) ) return;
foreach( $orders as $data ) {
$item = maybe_unserialize( $data->item );
$item['quantity'] = 1;
$item['material'] = $data->material;
$item['infill'] = 100;
$item['scale'] = 100;
$item['price'] = $data->payement_gross;
$item['amount'] = $data->payement_gross;
$item_data['firstname'] = '-';
$item_data['lastname'] = '-';
$item_data['email'] = $data->payer_email;
$item_data['txn_id'] = $data->txn_id;
$item_data['address'] = '-';
$item_data['city'] = '-';
$item_data['zipcode'] = '-';
$item_data['state'] = '-';
$item_data['email'] = '-';
$item_data['note'] = '';
$item_data['order_action'] = 'new';
$item_data['order_status'] = strtolower( $data->payement_status );
$item_data['coupon'] = '-';
$item_data['payment_method'] = '-';
$item_data['shipping_option'] = '-';
$item_data['shipping_cost'] = 0.00;
$item_data['cart_total'] = $data->payement_gross;
$item_data['subtotal'] = $data->payement_gross;
$item_data['total'] = $data->payement_gross;
$item_data['currency'] = $item['currency'];
$item_data['user_ip'] = '';
$item_data['user_id'] = '';
$item_data['pay_for_order_id'] = uniqid( pqc_get_random_string() );
$item_data['date'] = $data->date_created;
unset( $item['currency'] );
$item_data['items'][] = $item;
$args = array(
'post_title' => "#$data->ID",
'post_status' => 'publish',
'post_type' => 'pqc_order',
'post_date' => $data->date_created,
'post_date_gmt' => $data->date_created,
);
$post_id = wp_insert_post( $args );
// Insert Post Meta
update_post_meta( $post_id, 'pqc_order_data', $item_data );
}
}
/**
* Insert Default materials if no material exists
* @param bool $force Add materials whether there's result or no result
* @since 1.0
*/
private function insert_default_materials( $force = false )
{
$table = PQC_MATERIALS_TABLE;
if ( $this->table_exist( $table ) == 0 ) return;
global $wpdb;
// Let's check if there's data in the quotes table and add data if there's nothing
$result = $wpdb->get_var( "SELECT ID FROM $table" );
if ( $result && ! $force ) return;
$author = get_current_user_id();
$materials = array(
array( 'PP (poly propylene)', 0.90, '0.90' ),
array( 'HiPS (polystyrene)', 1.03, '1.03' ),
array( 'ABS', 1.04, '1.04' ),
array( 'BendLay', 1.05, '1.05' ),
array( 'E.P', 1.10, '1.10' ),
array( 'Proto-Pasta Conductive', 1.15, '1.15' ),
array( 'FilaFlex', 1.21, '1.21' ),
array( 'PLA', 1.24, '1.24' ),
array( 'PETG (Polyethylene)', 1.27, '1.27' ),
array( 'Timberfill - Wood', 1.28, '1.28' ),
array( 'Taulman Nylon 680 FDA', 1.28, '1.28' ),
array( 'Proto-Pasta Carbon Fiber', 1.30, '1.30' ),
array( 'PC (Polycarbonte)', 1.30, '1.30' ),
array( 'PETT (T-Glase)', 1.45, '1.45' ),
array( 'NylonStrong', 1.52, '1.52' ),
array( 'Proto-Pasta Magnetic', 2.00, '2.00' ),
array( 'Reflect-O-Lay', 2.31, '2.31' ),
array( 'Proto-Pasta Stainless Steel', 2.70, '2.70' ),
);
$date = current_time( 'mysql' );
foreach( $materials as $material ) {
$name = $material[0];
$cost = $material[1];
$dens = $material[2];
$desc = "Material Density: {$dens}g/cubic cm";
$data[] = "( $author, '$name', '$desc', '$cost', '$dens', '$date', '$date' )";
}
$data = implode( ', ', $data );
$sql = "INSERT INTO $table
( author, material_name, material_description, material_cost, material_density, date_created, date_modified )
VALUES $data";
$add = $wpdb->query( $sql );
}
/**
* Check if database table exists
* @since 1.0
* @param mixed $table_name
*/
private function table_exist( $table_name )
{
global $wpdb;
$check = "SHOW TABLES LIKE '$table_name'";
return ( $wpdb->get_var( $check ) ) ? 1 : 0;
}
/**
* Check if database colum exist in table
* @since 1.6
* @param mixed $table_name
* @param mixed $column_name
*/
private function column_exist( $table_name, $column_name )
{
global $wpdb;
if ( $this->table_exist( $table_name ) == 0 ) return 0;
$check = "SHOW COLUMNS FROM `$table_name` LIKE '$column_name';";
return ( $wpdb->get_var( $check ) ) ? 1 : 0;
}
/**
* Run Setup
* @since 1.0
*/
public function run_setup()
{
// Setup Database Tables
$this->setup_db_tables();
// Prepare options
$this->prepare_options();
// Add default pages
$this->add_default_pages();
if (
isset( $_REQUEST['pqc-add-default-materials'] ) &&
$_REQUEST['pqc-add-default-materials'] == 1
) {
// Add Default Materials, if no material
$this->insert_default_materials( true );
}
$license = get_option( 'pqc-license', false );
if ( ! $license || empty( $license ) ) {
$license = array(
'check_time' => strtotime( "+1 week" ),
);
update_option( 'pqc-license', $license );
}
if (
get_option( 'pqc-version', 'not exist' ) == 'not exist' ||
get_option( 'pqc-version' ) != PQC_VERSION
) {
if (
! get_option( 'pqc-version' ) ||
get_option( 'pqc-version', 'not exist' ) == 'not exist'
) {
$url = 'admin.php?page=pqc-start';
} elseif (
version_compare( get_option( 'pqc-version' ), PQC_VERSION, '<' )
) {
$url = 'admin.php?page=pqc-start&pqc-upgrade=1';
}
update_option( 'pqc-version', PQC_VERSION );
exit( wp_redirect( admin_url( $url ) ) );
} else {
wp_redirect(
admin_url(
'admin.php?page=pqc-settings-page&pqc-setup=complete'
)
);
exit;
}
}
/**
* Flushes Rewrite rules
* @since 1.0
*
*/
private function flush_rewrite_rules()
{
// Let's flush rewrite rules
flush_rewrite_rules( true );
}
/**
* Check and remove expired files and data
* @since 1.1.1
*/
private function remove_expired_files()
{
global $wpdb;
$table = PQC_DATA_TABLE;
if ( ! $this->table_exist( $table ) ) return;
$current_time = current_time( 'mysql' );
$query = "
SELECT unique_id FROM $table
WHERE expiry_date <= STR_TO_DATE( '$current_time', '%Y-%m-%d %H:%i:%s' );
";
$results = $wpdb->get_results( $query );
if ( ! $results || empty( $results ) ) return;
foreach( $results as $result ) {
$file = PQC_CONTENT_DIR . $result->unique_id . ".stl";
if ( file_exists( $file ) ) unlink( $file );
}
$query = "
DELETE FROM $table
WHERE expiry_date <= STR_TO_DATE( '$current_time', '%Y-%m-%d %H:%i:%s' );
";
$wpdb->query( $query );
}
/**
* Check if we have License
* @return bool
*/
public function has_valid_license()
{
$license = get_option( 'pqc-license', false );
if ( ! $license || empty( $license ) )
return false;
if ( empty( $license['code'] ) || strlen( $license['code'] ) === 20 )
return false;
if ( empty( $license['time'] ) || ! is_int( $license['time'] ) || $license['time'] < strtotime( current_time( 'mysql' ) ) )
return false;
if ( empty( $license['check_time'] ) || ! is_int( $license['check_time'] ) )
return false;
if ( $license['check_time'] <= strtotime( current_time( 'mysql' ) ) ) {
$check = $this->check_license( $license['code'] );
if ( ! $check || $check === false ) return false;
}
return true;
}
/**
* Checks for License
*
* @param string $code The License code
* @return bool
*/
public function check_license( $code )
{
require_once PQC_PATH . 'core/lib/wooskey-manager/wooskey-manager.php';
$wooskey = new WoosKey_Manager( PQC_PHANES_API_URI, $code );
$response = $wooskey->check_license();
if ( $response === true ) {
$this->license_response = array(
'code' => $code,
'msg' => $wooskey->response_msg,
'expires' => $wooskey->response_expires,
);
return true;
} elseif ( $response == null ) {
$this->license_response = array(
'code' => $code,
'msg' => $wooskey->response_msg,
);
return null;
}
$this->license_response = array(
'code' => $code,
'msg' => $wooskey->response_msg,
);
return false;
}
/**
* Handles JavaScript detection.
*
* Adds a `js` class to the root `` element when JavaScript is detected.
*/
public function js_detection()
{
echo '
' . "\n" ;
}
/**
* Internationalization
*
*/
public function i18n()
{
load_plugin_textdomain( 'pqc', false, dirname( PQC_PLUGIN ) . '/languages/' );
}
/**
* Add Extra Links for Plugin
*
* @param mixed $links
*/
public function plugin_links( $links )
{
$settings_link = '
' .
__( 'Settings', 'pqc' ) .
'';
$refresh_link = '
' .
__( 'Reset Plugin', 'pqc' ) .
'';
array_unshift( $links, $settings_link );
array_push( $links, $refresh_link );
return $links;
}
}
endif;
require_once 'functions.php';
$GLOBALS['pqc'] = PQC();