/** * Add to Visual Composer */ public function integrateWithVC() { $pricing_tables = GW_GoPricing_Data::get_tables('', false, 'title', 'ASC'); if (!empty($pricing_tables)) { foreach ($pricing_tables as $pricing_table) { if (!empty($pricing_table['name']) && !empty($pricing_table['id'])) { $dropdown_data[$pricing_table['name']] = $pricing_table['id']; } } } if (empty($dropdown_data)) { $dropdown_data[0] = __('No tables found!', 'go_pricing_textdomain'); } if (function_exists('vc_map')) { vc_map(array('name' => __('Go Pricing', 'go_pricing_textdomain'), 'description' => __('Awesome responsive pricing tables', 'go_pricing_textdomain'), 'base' => 'go_pricing', 'category' => __('Content', 'go_pricing_textdomain'), 'class' => '', 'controls' => 'full', 'icon' => plugin_dir_url(__FILE__) . 'assets/go_pricing_32x32.png', 'params' => array(array('type' => 'dropdown', 'heading' => __('Table Name', 'go_pricing_textdomain'), 'param_name' => 'id', 'value' => $dropdown_data, 'description' => __('Select Pricing Table', 'go_pricing_textdomain'), 'admin_label' => true)))); } }
/** * Do import * * @return bool */ public function save_table($data) { if (empty($data['name'])) { GW_GoPricing_AdminNotices::add('main', 'error', __('Pricing "Table Name" is empty!', 'go_pricing_textdomain'), false); } if (empty($data['id'])) { GW_GoPricing_AdminNotices::add('main', 'error', __('Pricing "Table ID" is empty!', 'go_pricing_textdomain'), false); } elseif (strlen($data['id']) >= 1 && preg_match('/([^a-z0-9\\-_])+/', $data['id']) == 1) { GW_GoPricing_AdminNotices::add('main', 'error', __('Pricing "Table ID" can contain only lowercase letters, numbers, hyphens and underscores!', 'go_pricing_textdomain'), false); } else { $tables = GW_GoPricing_Data::get_tables(); foreach ((array) $tables as $table_key => $table) { $table_ids[$table_key] = $table['id']; } if (!empty($data['postid']) && !empty($table_ids[$data['postid']])) { unset($table_ids[$data['postid']]); } if (in_array($data['id'], $table_ids)) { GW_GoPricing_AdminNotices::add('main', 'error', sprintf(__('Pricing table with an ID of "%s" already exists! It must be uniqe.', 'go_pricing_textdomain'), $data['id']), false); } } $notices = GW_GoPricing_AdminNotices::get('main', 'error'); if (isset($data['col-data'])) { $col_data = GW_GoPricing_Helper::clean_input($data['col-data'], 'html'); } $data = GW_GoPricing_Helper::clean_input($data); if (isset($col_data)) { $data['col-data'] = $col_data; } if (empty($notices)) { $data = GW_GoPricing_Helper::remove_input($data, array($_POST['action'])); $postid = GW_GoPricing_Data::update_table($data); if ($postid !== false) { // Create table message if (empty($data['postid'])) { GW_GoPricing_AdminNotices::add('main', 'success', sprintf(__('Pricing table has been successfully created!<br>Shortcode: </strong>[go_pricing id="%s"]<strong>', 'go_pricing_textdomain'), $data['id'])); } else { GW_GoPricing_AdminNotices::add('main', 'success', sprintf(__('Pricing table has been successfully updated!<br>Shortcode: </strong>[go_pricing id="%s"]<strong>', 'go_pricing_textdomain'), $data['id'])); } return $postid; } else { GW_GoPricing_AdminNotices::add('main', 'error', __('Oops, something went wrong!', 'go_pricing_textdomain')); } } else { $this->set_temp_postdata($data); } return false; }
/** * Import & Export Page - Main View */ // Prevent direct call if (!defined('WPINC')) { die; } if (!class_exists('GW_GoPricing')) { die; } // Get current user id $user_id = get_current_user_id(); // Get general settings $general_settings = get_option(self::$plugin_prefix . '_table_settings'); // Get pricing tables data $pricing_tables = GW_GoPricing_Data::get_tables(); ?> <!-- Top Bar --> <div class="gwa-ptopbar"> <div class="gwa-ptopbar-icon"></div> <div class="gwa-ptopbar-title">Go Pricing</div> <div class="gwa-ptopbar-content"><label><span class="gwa-label"><?php _e('Help', 'go_pricing_textdomain'); ?> </span><select data-action="help" class="gwa-w80"><option value="1"<?php echo isset($_COOKIE['go_pricing']['settings']['help'][$user_id]) && $_COOKIE['go_pricing']['settings']['help'][$user_id] == 1 ? ' selected="selected"' : ''; ?> ><?php _e('Tooltip', 'go_pricing_textdomain'); ?> </option><option value="2"<?php