public function output() { ?> <div class="wrap" id="fpd-product-builder"> <h2 class="fpd-clearfix"> <?php _e('Fancy Product Builder', 'radykal'); ?> <?php fpd_admin_display_version_info(); ?> </h2> <?php global $wpdb, $woocommerce; $request_view_id = isset($_GET['view_id']) ? $_GET['view_id'] : NULL; //get all fancy products $fancy_products = array(); if (fpd_table_exists(FPD_PRODUCTS_TABLE)) { $fancy_products = $wpdb->get_results("SELECT * FROM " . FPD_PRODUCTS_TABLE . " ORDER BY title ASC"); } if (sizeof($fancy_products) == 0) { echo '<div class="updated"><p><strong>' . __('There are no fancy products!', 'radykal') . '</strong></p></div></div>'; exit; } //save elements of view if (isset($_POST['save_elements'])) { check_admin_referer('fpd_save_elements'); $request_view_id = $_POST['view_id']; $elements = array(); for ($i = 0; $i < sizeof($_POST['element_types']); $i++) { $element = array(); $element['type'] = $_POST['element_types'][$i]; $element['title'] = $_POST['element_titles'][$i]; $element['source'] = $_POST['element_sources'][$i]; $parameters = array(); parse_str($_POST['element_parameters'][$i], $parameters); if (is_array($parameters)) { foreach ($parameters as $key => $value) { if ($value == '') { $parameters[$key] = NULL; } else { $parameters[$key] = preg_replace('/\\s+/', '', $value); } } } $element['parameters'] = $parameters; array_push($elements, $element); } $fancy_view = new Fancy_View($request_view_id); $fancy_view->update(array('elements' => serialize($elements))); $requested_view_elements = $elements; echo '<div class="updated"><p><strong>' . __('Elements saved.', 'radykal') . '</strong></p></div>'; } ?> <br class="clear" /> <p class="description"><?php _e('Select the view of your Fancy Product:', 'radykal'); ?> </p> <select id="fpd-view-switcher" class="radykal-select2" style="width: 38%;"> <?php if (is_array($fancy_products)) { foreach ($fancy_products as $fancy_product) { $fancy_product_id = $fancy_product->ID; echo '<optgroup label="' . $fancy_product->title . '" id="' . $fancy_product_id . '">'; $fancy_product = new Fancy_Product($fancy_product_id); $views = $fancy_product->get_views(); if (is_array($views)) { for ($i = 0; $i < sizeof($views); ++$i) { $view = $views[$i]; //get first view if ($request_view_id == NULL) { $request_view_id = $view->ID; } //get requested view if ($request_view_id == $view->ID && !isset($requested_view_elements)) { $requested_view_elements = unserialize($view->elements); } echo '<option value="' . $view->ID . '" ' . selected($request_view_id, $view->ID, false) . '>' . $view->title . '</option>'; } } echo '</optgroup>'; } } ?> </select> <?php //create instance of selected fancy view $fancy_view = new Fancy_View($request_view_id); $product_id = $fancy_view->get_product_id(); //get stage dimensions $fancy_product = new Fancy_Product($product_id); $stage_width = $fancy_product->get_option('stage_width'); $stage_height = $fancy_product->get_option('stage_height'); ?> <a href="#" id="fpd-save-layers" class="button-primary fpd-right"><?php _e('Save Layers', 'radykal'); ?> </a> <div id="fpd-layers-container" class="fpd-clearfix"> <!-- Manage elements --> <div id="fpd-manage-elements" class="fpd-panel"> <form method="post" id="fpd-submit"> <input type="submit" class="fpd-hidden" name="save_elements" /> <?php wp_nonce_field('fpd_save_elements'); ?> <h3 class="fpd-clearfix"> <span><?php _e('Layers', 'radykal'); ?> </span> </h3> <div id="fpd-add-element"> <a href="#" class="add-new-h2" id="fpd-add-image-element"><?php _e('Add Image', 'radykal'); ?> </a> <a href="#" class="add-new-h2" id="fpd-add-text-element"><?php _e('Add Text', 'radykal'); ?> </a> <a href="#" class="add-new-h2" id="fpd-add-curved-text-element"><?php _e('Add Curved Text', 'radykal'); ?> </a> <a href="#" class="add-new-h2" id="fpd-add-upload-zone"><?php _e('Add Upload Zone', 'radykal'); ?> </a> </div> <input type="hidden" value="<?php echo $request_view_id; ?> " name="view_id" /> <p class="description"><?php _e('Change the layer order by dragging elements up or down.', 'radykal'); ?> </p> <ul id="fpd-elements-list"> <?php $index = 0; if (is_array($requested_view_elements)) { foreach ($requested_view_elements as $view_element) { echo self::get_element_list_item($index, $view_element['title'], $view_element['type'], stripslashes($view_element['source']), http_build_query($view_element['parameters'])); $index++; } } ?> </ul> </form> </div> <!-- Edit Parameters --> <div id="fpd-edit-parameters" class="fpd-panel"> <h3><?php _e('Layer Options', 'radykal'); ?> : <span id="fpd-edit-parameters-for"></span></h3> <?php require_once FPD_PLUGIN_ADMIN_DIR . '/views/html-product-builder-parameters-form.php'; ?> </div> </div><!-- Manage Layers Box --> <!-- Product Stage --> <div id="fpd-product-stage" class="fpd-panel"> <h3 class="fpd-clearfix"><?php _e('Product Stage', 'radykal'); ?> <span class="description"><?php echo $stage_width; ?> px * <?php echo $stage_height; ?> px</span> </h3> <div id="fpd-element-toolbar"> <a href="#" class="button button-secondary fpd-center-horizontal"><?php _e('Center Horizontal', 'radykal'); ?> </a> <a href="#" class="button button-secondary fpd-center-vertical"><?php _e('Center Vertical', 'radykal'); ?> </a> <a href="#" class="button button-secondary fpd-dupliacte-layer"><?php _e('Duplicate Layer', 'radykal'); ?> </a> </div> <div id="fpd-fabric-stage-wrapper"> <canvas id="fpd-fabric-stage" width="<?php echo $stage_width; ?> " height="<?php echo $stage_height; ?> "></canvas> </div> </div> </div> <?php }
public function output() { global $wpdb; $page_links = false; if (isset($_POST['run_updater'])) { FPD_Install::do_upgrade('2.0.0'); update_option('fpd_hide_run_updater', 'yes'); } if (isset($_POST['fpd_filter_by'])) { update_option('fpd_admin_filter_by', $_POST['fpd_filter_by']); } if (isset($_POST['fpd_order_by'])) { update_option('fpd_admin_order_by', $_POST['fpd_order_by']); } $filter_by = get_option('fpd_admin_filter_by', 'title'); $order_by = get_option('fpd_admin_order_by', 'ASC'); $where = ''; if (isset($_POST['fpd_search_products_string']) && !empty($_POST['fpd_search_products_string'])) { $where = "WHERE title LIKE '%{$_POST['fpd_search_products_string']}%'"; } $categories = array(); if (fpd_table_exists(FPD_CATEGORIES_TABLE)) { $categories = $wpdb->get_results("SELECT * FROM " . FPD_CATEGORIES_TABLE . " ORDER BY title ASC"); } $products = array(); if (fpd_table_exists(FPD_PRODUCTS_TABLE)) { $pagenum = isset($_GET['paged']) ? absint($_GET['paged']) : 1; $limit = 20; $offset = ($pagenum - 1) * $limit; $total = $wpdb->get_var("SELECT COUNT(ID) FROM " . FPD_PRODUCTS_TABLE . ""); $num_of_pages = ceil($total / $limit); $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => '«', 'next_text' => '»', 'total' => $num_of_pages, 'current' => $pagenum)); $products = $wpdb->get_results("SELECT * FROM " . FPD_PRODUCTS_TABLE . " " . $where . " ORDER BY " . $filter_by . " " . $order_by . " LIMIT {$limit} OFFSET {$offset}"); } //select by category if (isset($_GET['category_id'])) { $page_links = false; $products = $wpdb->get_results("SELECT * FROM " . FPD_PRODUCTS_TABLE . " WHERE ID IN (SELECT product_id FROM " . FPD_CATEGORY_PRODUCTS_REL_TABLE . " WHERE category_id={$_GET['category_id']})"); } if (isset($_GET['info'])) { $info_url = $_GET['info'] == 'activated' ? 'http://assets.fancyproductdesigner.com/info-modals/installed.html' : 'http://assets.fancyproductdesigner.com/info-modals/updated.html'; require_once FPD_PLUGIN_ADMIN_DIR . '/modals/modal-updated-installed-info.php'; } require_once FPD_PLUGIN_ADMIN_DIR . '/modals/modal-load-demo.php'; require_once FPD_PLUGIN_ADMIN_DIR . '/modals/modal-load-template.php'; require_once FPD_PLUGIN_ADMIN_DIR . '/modals/modal-edit-product-options.php'; require_once FPD_PLUGIN_ADMIN_DIR . '/modals/modal-edit-view-options.php'; ?> <div class="wrap" id="fpd-manage-products"> <h2> <?php _e('Manage Fancy Products', 'radykal'); ?> <?php fpd_admin_display_version_info(); ?> </h2> <?php if (get_option('fpd_hide_run_updater', 'yes') !== 'yes') { ?> <div class="fpd-panel"> <h3>Update</h3> <p>Your action is required to update to the latest version.</p> <form method="POST"> <input type="submit" name="run_updater" value="Run Updater" class="button-primary" /> </form> </div> <?php } ?> <div class="fpd-clearfix"> <div id="fpd-products" class="fpd-panel"> <input type="file" value="Upload" class="fpd-hidden" id="fpd-file-import" /> <h3> <?php _e('Fancy Products', 'radykal'); ?> <a href="#" id="fpd-add-product" class="add-new-h2" style="float: none; margin-left: 10px;"><?php _e('Add New', 'radykal'); ?> </a> <a href="#" id="fpd-import-product" class="add-new-h2"><?php _e('Import', 'radykal'); ?> </a> <a href="#" id="fpd-load-template" class="add-new-h2"><?php _e('Load Template', 'radykal'); ?> </a> <a href="#" id="fpd-load-demo" class="add-new-h2 fpd-admin-tooltip" title="<?php _e('Load a demo to get started', 'radykal'); ?> "><?php _e('Load Demo', 'radykal'); ?> </a> </h3> <div id="fpd-products-nav" class="fpd-clearfix"> <form method="POST"> <span class="description"><?php _e('Filter:', 'radykal'); ?> </span> <select name="fpd_filter_by"> <option value="ID" <?php selected($filter_by, 'ID'); ?> ><?php _e('ID', 'radykal'); ?> </option> <option value="title" <?php selected($filter_by, 'title'); ?> ><?php _e('Title', 'radykal'); ?> </option> </select> <select name="fpd_order_by"> <option value="ASC" <?php selected($order_by, 'ASC'); ?> ><?php _e('Ascending', 'radykal'); ?> </option> <option value="DESC" <?php selected($order_by, 'DESC'); ?> ><?php _e('Descending', 'radykal'); ?> </option> </select> </form> <form method="POST" name="fpd_search_products"> <input type="text" name="fpd_search_products_string" placeholder="<?php _e('Search Fancy Products...', 'radykal'); ?> " /> <input type="submit" class="button button-secondary" value="<?php _e('Search', 'radykal'); ?> " /> </form> </div> <?php if (empty($products)) { ?> <p class="fpd-error-message"><strong><?php _e('No Fancy Products found!', 'radykal'); ?> </strong></p> <?php } ?> <ul id="fpd-products-list"> <?php foreach ($products as $product) { $fancy_product = new Fancy_Product($product->ID); $category_ids = $fancy_product->get_category_ids(); echo self::get_product_item_html($product->ID, $product->title, implode(',', $category_ids), stripslashes($product->options)); echo '<ul class="fpd-views-list">'; $product_views = $fancy_product->get_views(); if (!empty($product_views)) { foreach ($product_views as $view) { $view_options = isset($view->options) ? stripslashes($view->options) : ''; echo self::get_view_item_html($view->ID, $view->thumbnail, $view->title, $view_options); } } echo '</ul>'; } ?> </ul> <?php if ($page_links) { echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 0;">' . $page_links . '</div></div>'; } ?> <div class="fpd-ui-blocker"></div> </div> <div id="fpd-categories" class="fpd-panel"> <h3> <?php _e('Categories', 'radykal'); ?> <a href="#" id="fpd-add-category" class="add-new-h2"><?php _e('Add New', 'radykal'); ?> </a> </h3> <ul id="fpd-categories-list"> <?php foreach ($categories as $category) { echo self::get_category_item_html($category->ID, $category->title); } ?> </ul> <div class="fpd-ui-blocker"></div> </div> </div> </div> <?php }
public function settings_tables_start() { fpd_admin_display_version_info(); }
public function output() { ?> <div class="wrap" id="fpd-manage-designs"> <h2 class="fpd-clearfix"> <?php _e('Manage Fancy Designs', 'radykal'); ?> <a class="add-new-h2" href="<?php echo admin_url('edit-tags.php?taxonomy=fpd_design_category&post_type=attachment'); ?> "><?php _e('Create Category', 'radykal'); ?> </a> <?php fpd_admin_display_version_info(); ?> </h2> <?php //get all created categories $categories = get_terms('fpd_design_category', array('hide_empty' => false)); //check that categories are not empty if (empty($categories)) { echo '<div class="error"><p><strong>' . __('No categories found. You need to create a category first!', 'radykal') . '</strong></p></div></div>'; return false; } //select first category id $selected_category = $categories[0]; $selected_category_slug = $selected_category->slug; //loop through all categories foreach ($categories as $category) { //check if a category is selected if (isset($_POST['design_category']) && $_POST['design_category'] == $category->slug) { $selected_category = $category; $selected_category_slug = $selected_category->slug; } } if (isset($_POST['save_designs'])) { check_admin_referer('fpd_save_designs'); //remove all designs from design category $args = array('posts_per_page' => -1, 'post_type' => 'attachment', 'fpd_design_category' => $selected_category_slug); //get all attachments and remove the from category $designs = get_posts($args); foreach ($designs as $design) { wp_delete_object_term_relationships($design->ID, 'fpd_design_category'); } $order = 0; //loop through all submitted images foreach ($_POST['image_ids'] as $image_id) { //update menu order $attachment = array('ID' => $image_id, 'menu_order' => $order); wp_update_post($attachment); //set relation between image and design category wp_set_object_terms($image_id, $selected_category_slug, 'fpd_design_category', true); //set parameters for design update_post_meta($image_id, 'fpd_parameters', $_POST['parameters'][$order]); update_post_meta($image_id, 'fpd_thumbnail', $_POST['thumbnail'][$order]); $order++; } update_option('fpd_category_parameters_' . $selected_category_slug, $_POST['fpd_category_options']); echo '<div class="updated"><p><strong>' . __('Designs saved.', 'radykal') . '</strong></p></div>'; } //get category parametes $category_parameters = get_option('fpd_category_parameters_' . $selected_category_slug); ?> <br class="clear" /> <?php require_once FPD_PLUGIN_ADMIN_DIR . '/modals/modal-edit-design-category-options.php'; ?> <form method="post" id="fpd-designs-form"> <div> <p class="description"><?php _e('Categories', 'radykal'); ?> </p> <select name="design_category" class="radykal-select2" style="width: 400px;"> <?php foreach ($categories as $category) { $selected = ''; //check if a category is selected if (isset($_POST['design_category']) && $_POST['design_category'] == $category->slug) { $selected = 'selected="selected"'; } //output category option echo '<option value="' . $category->slug . '" ' . $selected . '>' . $category->name . '</option>'; } ?> </select> </div> <br /><br /> <p class="description"><?php _e('Designs in "', 'radykal'); echo $selected_category->name . '"'; ?> </p> <div class="fpd-panel"> <?php ?> <input type="hidden" value="<?php if ($category_parameters) { echo $category_parameters; } ?> " name="fpd_category_options" /> <a href="#" class="add-new-h2 fpd-add-designs"><?php _e('Add Designs', 'radykal'); ?> </a> <a href="#" id="fpd-edit-category-options" class="add-new-h2"><?php _e('Edit Category Options', 'radykal'); ?> </a> <div id="fpd-black-white-switcher" class="fpd-right"> <a href="#" id="fpd-white"></a> <a href="#" id="fpd-black"></a> </div> <div class="inside"> <ul id="fpd-designs-list" class="fpd-clearfix"> <?php //get designs by category id $args = array('posts_per_page' => -1, 'post_type' => 'attachment', 'orderby' => 'menu_order', 'order' => 'ASC', 'fpd_design_category' => $selected_category_slug); $designs = get_posts($args); //loop through all designs foreach ($designs as $design) { $parameters = get_post_meta($design->ID, 'fpd_parameters', true); $thumbnail = get_post_meta($design->ID, 'fpd_thumbnail', true); echo '<li><img src="' . $design->guid . '" /><a href="#" class="fpd-edit-parameters"><i class="fpd-admin-icon-settings"></i></a><a href="#" class="fpd-remove-design"><i class="fpd-admin-icon-close"></i></a><input type="hidden" value="' . $design->ID . '" name="image_ids[]" /><input type="hidden" value="' . $parameters . '" name="parameters[]" /><input type="hidden" value="' . $thumbnail . '" name="thumbnail[]" /></li>'; } ?> </ul> </div> </div> <?php wp_nonce_field('fpd_save_designs'); ?> <input type="submit" name="save_designs" value="<?php _e('Save Changes', 'radykal'); ?> " class="button button-primary" /> </form> </div> <?php }
public function output() { if (class_exists('FPD_Admin_Order')) { global $wpdb; $pagenum = isset($_GET['paged']) ? absint($_GET['paged']) : 1; $limit = 5; $offset = ($pagenum - 1) * $limit; $total = $wpdb->get_var("SELECT COUNT(ID) FROM " . FPD_ORDERS_TABLE . ""); $num_of_pages = ceil($total / $limit); $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'prev_text' => __('«', 'text-domain'), 'next_text' => __('»', 'text-domain'), 'total' => $num_of_pages, 'current' => $pagenum)); ?> <div class="wrap" id="fpd-orders"> <h2 class="fpd-clearfix"> <?php _e('Orders via Shortcode', 'radykal'); ?> <?php fpd_admin_display_version_info(); ?> </h2> <?php if (function_exists('get_woocommerce_currency')) { ?> <div class="updated"> <p><strong><?php _e('Orders made with WooCommerce can be viewed in the order details of a WooCommerce order!', 'radykal'); ?> </strong></p> </div> <?php } ?> <div class="fpd-panel"> <h3><?php _e('Choose Order', 'radykal'); ?> </h3> <ul id="fpd-shortcode-orders-list"> <?php $orders = FPD_Shortcode_Order::get_orders($limit, $offset); if (is_array($orders)) { foreach ($orders as $order) { echo $this->get_order_list_item($order->ID, $order->customer_name, $order->customer_mail, fpd_update_image_source($order->views)); } } ?> </ul> <?php if ($page_links) { echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 0;">' . $page_links . '</div></div>'; } ?> </div> <div class="fpd-panel"> <h3><?php _e('Order Viewer', 'radykal'); ?> </h3> <?php FPD_Admin_Order::output(); ?> </div> </div> <script type="text/javascript"> jQuery(document).ready(function($) { var $ordersList = $('#fpd-shortcode-orders-list'); $ordersList.on('click', 'li', function() { if(!loadingProduct) { $ordersList.children('li').removeClass('fpd-active'); var $this = $(this).addClass('fpd-active'), order = $this.data('views'); orderId = $this.data('id'); fpdLoadOrder(order); } }); $ordersList.on('click', '.fpd-remove-order', function(evt) { evt.preventDefault(); evt.stopPropagation(); var c = confirm(fpd_admin_opts.remove); if(c) { $.ajax({ url: fpd_admin_opts.adminAjaxUrl, data: { action: 'fpd_removeshortcodeorder', _ajax_nonce: fpd_admin_opts.ajaxNonce, id: $(this).parents('li').data('id') }, type: 'post', dataType: 'json', success: function(data) { if(data == 0) { fpdMessage(fpd_admin_opts.tryAgain, 'error'); } else { location.reload(); } } }); } }); }); </script> <?php } }