<?php

/**
 * @package CSSJockey WordPress Framework
 * @author Mohit Aneja (cssjockey.com)
 * @version FW-20150208
*/
global $wpdb;
$installed_table_names = cjtheme_item_info('options_table') . '<br>';
if (!is_null(cjtheme_item_info('addon_tables'))) {
    $installed_addon_tables = explode(',', cjtheme_item_info('addon_tables'));
    foreach ($installed_addon_tables as $key => $value) {
        $installed_table_names .= $wpdb->prefix . $value . '<br />';
    }
}
$cjtheme_form_options['ncuninstall'] = array(array('type' => 'sub-heading', 'id' => 'ncuninstall_heading', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('Uninstall %s', 'cjtheme'), ucwords(cjtheme_item_info('item_type'))), 'options' => ''), array('type' => 'info-full', 'id' => 'nctrial_info', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => __('<p>To uninstall this plugin, you can deactivate this plugin and then remove the following tables from your databse.</p>', 'cjtheme') . $installed_table_names, 'options' => ''));
cjtheme_admin_form_raw($cjtheme_form_options['ncuninstall']);
 * @package CSSJockey WordPress Framework
 * @author Mohit Aneja (cssjockey.com)
 * @version FW-20150208
*/
$help_support_value[] = '<a href="' . cjtheme_item_info('quick_start_guide_url') . '" target="_blank">' . __('Quick Start Guide', 'cjtheme') . '</a>';
$help_support_value[] = '<a href="' . cjtheme_item_info('documentation_url') . '" target="_blank">' . __('Documentation', 'cjtheme') . '</a>';
$help_support_value[] = '<a href="' . cjtheme_item_info('support_forum_url') . '" target="_blank">' . __('Support Fourm', 'cjtheme') . '</a>';
if (isset($_REQUEST['cjmsg']) && $_REQUEST['cjmsg'] == 'pc-no-match') {
    echo cjtheme_show_message('error', sprintf(__('Could not reset your license for this installation. <br><a target="_blank" href="%s">Click here</a> to create a support ticket.', 'cjtheme'), cjtheme_item_info('support_forum_url')));
}
$cjtheme_purchase_code = '';
$eon = sha1('cjtheme_verify_epc' . site_url());
$eov = get_option($eon);
if ($eov != '') {
    $cjtheme_purchase_code = array('type' => 'info', 'id' => 'cjtheme_purchase_code', 'label' => __('Purchase code', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => '<span class="btn btn-success btn-sm" style=" margin-right: 10px;"><i class="fa fa-check-circle"></i>&nbsp;&nbsp;' . __('Verified & Active', 'cjtheme') . '</span>' . sprintf('<a href="%s" class="btn btn-danger btn-sm cj-confirm" data-confirm="%s">Reset License</a>', cjtheme_string(cjtheme_callback_url('core_welcome')) . 'cjtheme_action=reset-license', __("Are you sure?\nThis will reset your license for this installation.\nYou may use this license again on any installation.", 'cjtheme')), 'options' => '');
} else {
    $cjtheme_purchase_code = array('type' => 'info', 'id' => 'cjtheme_purchase_code', 'label' => __('Purchase code', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => '<span class="label label-danger" style="padding:5px 10px; font-size:14px; font-weight:normal;"><i class="fa fa-times-circle"></i>&nbsp;&nbsp;' . __('Not Verified', 'cjtheme') . '</span>', 'options' => '');
}
if (cjtheme_is_local()) {
    $cjtheme_purchase_code = array('type' => 'info', 'id' => 'cjtheme_purchase_code', 'label' => __('Purchase code', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => '<span class="label label-default" style="padding:5px 10px; font-size:14px; font-weight:normal;"><i class="fa fa-info-circle"></i>&nbsp;&nbsp;' . __('Local Server', 'cjtheme') . '</span><span class="margin-10-left italic red">' . __('You will be asked to validate your purchase code to use this product on live server.', 'cjtheme') . '</span>', 'options' => '');
}
if (cjtheme_item_info('item_id') == 'NA') {
    $cjtheme_purchase_code = null;
    $contribute = null;
} else {
    $contribute = array('type' => 'info', 'id' => 'contribute', 'label' => __('Contribute', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('<p>You can contribute to support further development and new features for this product.</p> <p><a target="_blank" class="btn btn-danger" href="%s">Contribute</a></p>', 'cjtheme'), 'http://cssjockey.com/contribute'), 'options' => '');
}
$localization_string = sprintf(__('You can download <a class="bold" target="_blank" href="%s">Loco Translate WordPress Plugin (FREE)</a> to easily create language files within your WordPress dashboard without using Poedit software.', 'cjtheme'), 'https://wordpress.org/plugins/loco-translate/');
$cjtheme_form_options['welcome'] = array(array('type' => 'sub-heading', 'id' => 'welcome_heading', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('%s Information', 'cjtheme'), ucwords(cjtheme_item_info('item_type'))), 'options' => ''), array('type' => 'info', 'id' => 'product_type', 'label' => __('Product Type', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('WordPress %s', 'cjtheme'), ucwords(cjtheme_item_info('item_type'))), 'options' => ''), array('type' => 'info', 'id' => 'product_name', 'label' => __('Product Name', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => cjtheme_item_info('item_name'), 'options' => ''), array('type' => 'info', 'id' => 'product_id', 'label' => __('Product ID', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => cjtheme_item_info('item_id'), 'options' => ''), array('type' => 'info', 'id' => 'version', 'label' => __('Installed Version', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => cjtheme_item_info('item_version'), 'options' => ''), $cjtheme_purchase_code, array('type' => 'info', 'id' => 'license', 'label' => __('License & Terms of use', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('<a target="_blank" href="%s">Click here</a> to view license and terms of use.', 'cjtheme'), cjtheme_item_info('license_url')), 'options' => ''), array('type' => 'info', 'id' => 'help_support', 'label' => __('Help & Support', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => implode(' &nbsp; &bull; &nbsp; ', $help_support_value), 'options' => ''), array('type' => 'info', 'id' => 'translate', 'label' => __('Localization', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => $localization_string, 'options' => ''), $contribute);
cjtheme_admin_form_raw($cjtheme_form_options['welcome']);
do_action('cjtheme_after_welcome_panel');
<?php

/**
 * @package CSSJockey WordPress Framework
 * @author Mohit Aneja (cssjockey.com)
 * @version FW-20150208
*/
global $wpdb;
$options_table = cjtheme_item_info('options_table');
$settings = $wpdb->get_results("SELECT * FROM {$options_table}");
$export_settings = urlencode(serialize($settings));
$cjtheme_form_options['export_settings'] = array(array('type' => 'sub-heading', 'id' => 'export_heading', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('Export %s Settings', 'cjtheme'), ucwords(cjtheme_item_info('item_type'))), 'options' => ''), array('type' => 'textarea-readonly', 'id' => 'export_settings', 'label' => __('Export Settings', 'cjtheme'), 'info' => __('Copy the contents and save it in a text file.', 'cjtheme'), 'suffix' => '', 'prefix' => '', 'default' => cjtheme_post_default('export_settings', $export_settings), 'options' => '', 'params' => ' onclick="this.focus();this.select()" '));
cjtheme_admin_form_raw($cjtheme_form_options['export_settings']);
if (isset($_POST['do_import_settings'])) {
    $import_settings = unserialize(urldecode($_POST['import_settings']));
    if (is_array($import_settings)) {
        $wpdb->query("TRUNCATE TABLE {$options_table}");
        foreach ($import_settings as $key => $value) {
            $insert_data = array('option_name' => $value->option_name, 'option_value' => $value->option_value);
            cjtheme_insert($options_table, $insert_data);
        }
        $location = cjtheme_callback_url();
        wp_redirect($location, $status = 302);
        exit;
    }
}
$cjtheme_form_options['import_settings'] = array(array('type' => 'heading', 'id' => 'import_heading', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('Import %s Settings', 'cjtheme'), ucwords(cjtheme_item_info('item_type'))), 'options' => ''), array('type' => 'textarea', 'id' => 'import_settings', 'label' => __('Import Settings', 'cjtheme'), 'info' => __('Paste the previously copied settings and click Import Settings.', 'cjtheme'), 'suffix' => '', 'prefix' => '', 'default' => '', 'options' => ''), array('type' => 'submit', 'id' => 'do_import_settings', 'label' => __('Import Settings', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => '', 'options' => ''));
echo '<form class="margin-30-top" action="' . admin_url('admin.php?page=' . @$_GET['page'] . '&callback=' . @$_GET['callback'] . '') . '" method="post" enctype="multipart/form-data">';
cjtheme_admin_form_raw($cjtheme_form_options['import_settings']);
echo '</form>';
        $cjtheme_upgrade_errors[] = __('Envato API Key is required.', 'cjtheme');
    } elseif ($_POST['cjtheme_envato_purchase_code'] == '') {
        $cjtheme_upgrade_errors[] = __('Envato Item Purchase Code is required.', 'cjtheme');
    } else {
        $url = 'http://marketplace.envato.com/api/v3/cssjockey/c2u03ax2x2iwd6hbxfxt1ixmn5sqi74w/verify-purchase:' . $_POST['cjtheme_envato_purchase_code'] . '.json';
        $response = wp_remote_get($url);
        if (is_wp_error($response)) {
            $cjtheme_upgrade_errors[] = $response->get_error_message();
        } else {
            $response = json_decode($response['body']);
            foreach ($response as $key => $value) {
                if (!isset($value->item_id)) {
                    $cjtheme_upgrade_errors[] = __('Could not verify purchase, please try again.', 'cjtheme');
                } else {
                    update_option('cjtheme_envato_item_id', $value->item_id);
                }
            }
        }
    }
    if (!is_null($cjtheme_upgrade_errors)) {
        echo cjtheme_show_message('error', implode('<br>', $cjtheme_upgrade_errors));
    } else {
        update_option('cjtheme_envato_username', $_POST['cjtheme_envato_username']);
        update_option('cjtheme_envato_api_key', $_POST['cjtheme_envato_api_key']);
        update_option('cjtheme_envato_purchase_code', $_POST['cjtheme_envato_purchase_code']);
    }
}
$cjtheme_form_options['envato_api_info'] = array(array('type' => 'sub-heading', 'id' => 'envato_info_heading', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => sprintf(__('%s ~ Verify Purchase', 'cjtheme'), cjtheme_item_info('item_name')), 'options' => ''), array('type' => 'text', 'id' => 'cjtheme_envato_username', 'label' => __('Envato Username', 'cjtheme'), 'info' => __('Specify your envato username here', 'cjtheme'), 'suffix' => '', 'prefix' => '', 'default' => get_option('cjtheme_envato_username'), 'options' => ''), array('type' => 'text', 'id' => 'cjtheme_envato_api_key', 'label' => __('Envato API Key', 'cjtheme'), 'info' => __('Specify your envato API Key here.<br>You can create or get your API Key from Envato Profile >> Settings >> API Keys.', 'cjtheme'), 'suffix' => '', 'prefix' => '', 'default' => get_option('cjtheme_envato_api_key'), 'options' => ''), array('type' => 'text', 'id' => 'cjtheme_envato_purchase_code', 'label' => __('Purchase Code', 'cjtheme'), 'info' => __('Enter your item purchase code here.<br>You can download your purchase from Envato Profile >> Downloads Page', 'cjtheme'), 'suffix' => '', 'prefix' => '', 'default' => get_option('cjtheme_envato_purchase_code'), 'options' => ''), array('type' => 'submit', 'id' => 'save_envato_info', 'label' => __('Verify Purchase', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => '', 'options' => ''));
echo '<form action="" method="post">';
cjtheme_admin_form_raw($cjtheme_form_options['envato_api_info']);
echo '</form>';
function cjtheme_fetch_shortcode_options()
{
    global $wpdb, $shortcode_tags;
    $select_shortcodes = null;
    $shortcode_options = cjtheme_do_shortcode('[' . $_POST['shortcode'] . ' return="options"]');
    $shortcode_options = is_serialized($shortcode_options) ? unserialize($shortcode_options) : $shortcode_options;
    $shortcode_defaults = cjtheme_do_shortcode('[' . $_POST['shortcode'] . ' return="defaults"]');
    $shortcode_defaults = is_serialized($shortcode_defaults) ? unserialize($shortcode_defaults) : $shortcode_defaults;
    $form_fields[] = array('type' => 'heading', 'id' => 'shortcode-settings-heading', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => __('Shortcode Settings', 'cjtheme'), 'options' => '');
    if (!is_null($shortcode_options['description'])) {
        $form_fields[] = array('type' => 'info-full', 'id' => 'shortcode_info', 'label' => '', 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => $shortcode_options['description'], 'options' => '');
    }
    if ($shortcode_options['stype'] == 'closed' && isset($shortcode_options['default_content']) && $shortcode_options['default_content'] != '') {
        $form_fields[] = array('type' => 'textarea', 'id' => 'shortcode_content', 'label' => __('Content', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => $shortcode_options['default_content'], 'options' => '');
    }
    foreach ($shortcode_options as $key => $options) {
        if (is_array($options)) {
            $form_fields[] = array('type' => $options[1], 'id' => $key, 'label' => $options[0], 'info' => $options[3], 'suffix' => '', 'prefix' => '', 'default' => isset($shortcode_defaults[$key]) ? $shortcode_defaults[$key] : '', 'options' => is_array($options[2]) ? $options[2] : '');
        }
    }
    $form_fields[] = array('type' => 'submit', 'id' => 'cj-insert-shortcode', 'label' => __('Insert Shortcode', 'cjtheme'), 'info' => '', 'suffix' => '', 'prefix' => '', 'default' => '', 'options' => '');
    echo '<div class="cj-table">';
    echo '<form action="" method="post" id="cj-shortcode-settings-form" data-shortcode-stype="' . $shortcode_options['stype'] . '" data-shortcode-name="' . $_POST['shortcode'] . '">';
    echo cjtheme_admin_form_raw($form_fields, 'no-search-box', true);
    echo '</form>';
    echo '</div>';
    die;
}