| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
|
| 4 |
/* |
| 5 |
Plugin Name: PickPlugins Product Designer for WooCommerce |
| 6 |
Plugin URI: https://www.pickplugins.com/item/product-designer/?ref=dashboard |
| 7 |
Description: Awesome Product Designer for Woo-Commenrce. |
| 8 |
Version: 1.0.40 |
| 9 |
WC requires at least: 3.0.0 |
| 10 |
WC tested up to: 9.1 |
| 11 |
Author: PickPlugins |
| 12 |
Author URI: http://pickplugins.com |
| 13 |
Text Domain: product-designer |
| 14 |
License: GPLv2 or later |
| 15 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html |
| 16 |
*/ |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
class ProductDesigner |
| 21 |
{ |
| 22 |
|
| 23 |
public function __construct() |
| 24 |
{ |
| 25 |
|
| 26 |
|
| 27 |
define('product_designer_plugin_url', plugins_url('/', __FILE__)); |
| 28 |
define('product_designer_plugin_dir', plugin_dir_path(__FILE__)); |
| 29 |
define('product_designer_plugin_name', 'Product Designer'); |
| 30 |
define('product_designer_plugin_version', '1.0.40'); |
| 31 |
|
| 32 |
require_once(product_designer_plugin_dir . 'includes/class-settings-tabs.php'); |
| 33 |
require_once(product_designer_plugin_dir . 'includes/class-request-reviews.php'); |
| 34 |
|
| 35 |
require_once(product_designer_plugin_dir . 'includes/class-functions.php'); |
| 36 |
require_once(product_designer_plugin_dir . 'includes/class-shortcodes.php'); |
| 37 |
require_once(product_designer_plugin_dir . 'includes/class-settings.php'); |
| 38 |
require_once(product_designer_plugin_dir . 'includes/class-posttypes.php'); |
| 39 |
require_once(product_designer_plugin_dir . 'includes/class-post-meta.php'); |
| 40 |
require_once(product_designer_plugin_dir . 'includes/functions-wc.php'); |
| 41 |
require_once(product_designer_plugin_dir . 'includes/settings-hook.php'); |
| 42 |
require_once(product_designer_plugin_dir . 'templates/product-designer/product-designer-hook.php'); |
| 43 |
|
| 44 |
require_once(product_designer_plugin_dir . 'includes/metabox-pd_template-hook.php'); |
| 45 |
require_once(product_designer_plugin_dir . 'includes/class-meta-boxes.php'); |
| 46 |
require_once(product_designer_plugin_dir . 'includes/metabox-clipart-hook.php'); |
| 47 |
require_once(product_designer_plugin_dir . 'includes/metabox-shape-hook.php'); |
| 48 |
|
| 49 |
|
| 50 |
//require_once( product_designer_plugin_dir . 'includes/tshirt-designer-meta.php'); |
| 51 |
|
| 52 |
//require_once( product_designer_plugin_dir . 'includes/designer.php'); |
| 53 |
require_once(product_designer_plugin_dir . 'includes/designer-function.php'); |
| 54 |
|
| 55 |
add_action('wp_enqueue_scripts', array($this, '_front_scripts')); |
| 56 |
add_action('admin_enqueue_scripts', array($this, '_admin_scripts')); |
| 57 |
add_action('admin_enqueue_scripts', 'wp_enqueue_media'); |
| 58 |
add_action('plugins_loaded', array($this, 'load_textdomain')); |
| 59 |
add_action('before_woocommerce_init', array($this, 'high_performance_order_storage')); |
| 60 |
|
| 61 |
add_filter('widget_text', 'do_shortcode'); |
| 62 |
|
| 63 |
register_activation_hook(__FILE__, array($this, '_activation')); |
| 64 |
|
| 65 |
$args = array( |
| 66 |
'option_name' => 'product_designer_settings', |
| 67 |
'review_url' => 'https://wordpress.org/support/plugin/product-designer/reviews/#new-post', |
| 68 |
'plugin_name' => 'Product Designer', |
| 69 |
|
| 70 |
); |
| 71 |
|
| 72 |
$pickplugins_request_reviews = new pickplugins_request_reviews($args); |
| 73 |
} |
| 74 |
|
| 75 |
function high_performance_order_storage() |
| 76 |
{ |
| 77 |
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) { |
| 78 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true); |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
public function load_textdomain() |
| 83 |
{ |
| 84 |
|
| 85 |
|
| 86 |
$locale = apply_filters('plugin_locale', get_locale(), 'product-designer'); |
| 87 |
load_textdomain('product-designer', WP_LANG_DIR . '/product-designer/product-designer-' . $locale . '.mo'); |
| 88 |
|
| 89 |
load_plugin_textdomain('product-designer', false, plugin_basename(dirname(__FILE__)) . '/languages/'); |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
public function _activation() |
| 94 |
{ |
| 95 |
|
| 96 |
$product_designer_settings = get_option('product_designer_settings'); |
| 97 |
$product_designer_page_id = get_option('product_designer_page_id'); |
| 98 |
|
| 99 |
|
| 100 |
$designer_page_id = isset($product_designer_settings['designer_page_id']) ? $product_designer_settings['designer_page_id'] : ''; |
| 101 |
|
| 102 |
|
| 103 |
if (empty($designer_page_id)) : |
| 104 |
|
| 105 |
if (!empty($product_designer_page_id)) { |
| 106 |
$page_id = $product_designer_page_id; |
| 107 |
} else { |
| 108 |
$page_id = wp_insert_post(array( |
| 109 |
'post_title' => __('Designer', 'product-designer'), |
| 110 |
'slug' => 'designer', |
| 111 |
'post_type' => 'page', |
| 112 |
'post_status' => 'publish', |
| 113 |
'post_content' => '[product_designer]', |
| 114 |
)); |
| 115 |
} |
| 116 |
|
| 117 |
$product_designer_settings['designer_page_id'] = $page_id; |
| 118 |
|
| 119 |
endif; |
| 120 |
|
| 121 |
$product_designer_settings['font_aw_version'] = 'v_4'; |
| 122 |
|
| 123 |
|
| 124 |
update_option('product_designer_settings', $product_designer_settings); |
| 125 |
|
| 126 |
|
| 127 |
do_action('product_designer_activation'); |
| 128 |
} |
| 129 |
|
| 130 |
public function _uninstall() |
| 131 |
{ |
| 132 |
|
| 133 |
do_action('product_designer_uninstall'); |
| 134 |
} |
| 135 |
|
| 136 |
public function _deactivation() |
| 137 |
{ |
| 138 |
|
| 139 |
do_action('product_designer_deactivation'); |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
public function _front_scripts() |
| 144 |
{ |
| 145 |
|
| 146 |
|
| 147 |
wp_register_style('customize-link', product_designer_plugin_url . 'assets/front/css/customize-link.css'); |
| 148 |
|
| 149 |
|
| 150 |
wp_register_script('jquery-impromptu', plugins_url('/assets/front/js/jquery-impromptu.min.js', __FILE__), array('jquery')); |
| 151 |
wp_register_style('jquery-impromptu', product_designer_plugin_url . 'assets/front/css/jquery-impromptu.min.css'); |
| 152 |
|
| 153 |
|
| 154 |
wp_register_script('jscolor', plugins_url('assets/front/js/jscolor.js', __FILE__), array('jquery'), '1.0', false); |
| 155 |
wp_register_script('fabric.js', plugins_url('/assets/front/js/fabric.min.js', __FILE__), array('jquery'), '1.0', false); |
| 156 |
//wp_register_script( 'fabric.js', plugins_url( '/assets/front/js/fabric-4.4.0.min.js', __FILE__ ), array('jquery'), '1.0', false); |
| 157 |
|
| 158 |
wp_register_script('jquery.scrollbar', plugins_url('/assets/front/js/jquery.scrollbar.min.js', __FILE__), array('jquery'), '1.0', false); |
| 159 |
|
| 160 |
wp_register_script('product_designer_js', plugins_url('/assets/front/js/product-designer.js', __FILE__), array('jquery')); |
| 161 |
wp_localize_script('product_designer_js', 'product_designer_ajax', array('product_designer_ajaxurl' => admin_url('admin-ajax.php'))); |
| 162 |
|
| 163 |
|
| 164 |
wp_localize_script('product_designer_js', 'product_designer_ajax', array('product_designer_ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('product_designer_nonce'))); |
| 165 |
|
| 166 |
|
| 167 |
wp_register_script('fabric.curvedText', plugins_url('/assets/front/js/fabric.curvedText.js', __FILE__), array('jquery')); |
| 168 |
|
| 169 |
wp_register_style('font-awesome-4', product_designer_plugin_url . 'assets/global/css/font-awesome-4.css'); |
| 170 |
wp_register_style('font-awesome-5', product_designer_plugin_url . 'assets/global/css/font-awesome-5.css'); |
| 171 |
wp_register_style('hint.min', product_designer_plugin_url . 'assets/front/css/hint.min.css'); |
| 172 |
wp_register_style('product-designer-editor', product_designer_plugin_url . 'assets/front/css/product-designer.css'); |
| 173 |
wp_register_style('FontCPD', product_designer_plugin_url . 'assets/front/css/FontCPD/FontCPD.css'); |
| 174 |
wp_register_style('jquery.scrollbar', product_designer_plugin_url . 'assets/front/css/jquery.scrollbar.css'); |
| 175 |
wp_enqueue_script('jquery-qrcode.min', plugins_url('/assets/front/js/jquery-qrcode.min.js', __FILE__), array('jquery')); |
| 176 |
wp_enqueue_script('JsBarcode.all.min.js', plugins_url('assets/front/js/JsBarcode.all.min.js', __FILE__), array('jquery'), '1.0', false); |
| 177 |
|
| 178 |
if (isset($_GET['pd_enable']) || isset($_GET['product_id'])) { |
| 179 |
wp_enqueue_script('fabric.js'); |
| 180 |
wp_enqueue_script('fabric.curvedText'); |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
do_action('product_designer_front_scripts'); |
| 187 |
} |
| 188 |
|
| 189 |
public function _admin_scripts() |
| 190 |
{ |
| 191 |
|
| 192 |
$screen = get_current_screen(); |
| 193 |
|
| 194 |
//var_dump($screen); |
| 195 |
|
| 196 |
|
| 197 |
wp_enqueue_script('jquery'); |
| 198 |
wp_enqueue_script('jquery-ui-sortable'); |
| 199 |
|
| 200 |
wp_enqueue_script('product_designer_js', plugins_url('/assets/admin/js/scripts.js', __FILE__), array('jquery')); |
| 201 |
wp_localize_script('product_designer_js', 'product_designer_ajax', array('product_designer_ajaxurl' => admin_url('admin-ajax.php'))); |
| 202 |
|
| 203 |
wp_enqueue_style('product_designer_admin', product_designer_plugin_url . 'assets/admin/css/style.css'); |
| 204 |
wp_enqueue_style('product_designer_style-templates', product_designer_plugin_url . 'assets/admin/css/style-templates.css'); |
| 205 |
wp_register_script('jquery.lazy', product_designer_plugin_url . 'assets/admin/js/jquery.lazy.js', array('jquery')); |
| 206 |
|
| 207 |
//wp_enqueue_style('font-awesome.min', product_designer_plugin_url.'assets/global/css/font-awesome.min.css'); |
| 208 |
|
| 209 |
//wp_enqueue_style( 'wp-color-picker' ); |
| 210 |
//wp_enqueue_script( 'product_designer_color_picker', plugins_url('/js/color-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true ); |
| 211 |
wp_register_style('font-awesome-4', product_designer_plugin_url . 'assets/global/css/font-awesome-4.css'); |
| 212 |
wp_register_style('font-awesome-5', product_designer_plugin_url . 'assets/global/css/font-awesome-5.css'); |
| 213 |
|
| 214 |
wp_register_style('settings-tabs', product_designer_plugin_url . 'assets/settings-tabs/settings-tabs.css'); |
| 215 |
wp_register_script('settings-tabs', product_designer_plugin_url . 'assets/settings-tabs/settings-tabs.js', array('jquery')); |
| 216 |
|
| 217 |
|
| 218 |
if ($screen->id == 'shop_order' || $screen->id == 'pd_template') { |
| 219 |
|
| 220 |
$settings_tabs_field = new settings_tabs_field(); |
| 221 |
$settings_tabs_field->admin_scripts(); |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
do_action('product_designer_admin_scripts'); |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
new ProductDesigner(); |
| 230 |
|