function cjtheme_theme_scripts() { if (!is_admin()) { global $wp_styles, $wp_scripts; $theme_version = cjtheme_item_info('item_version'); $theme_dir = get_template_directory(); $theme_url = get_template_directory_uri(); $cjtheme_google_fonts_string = cjtheme_google_fonts_string(); if (!is_null($cjtheme_google_fonts_string)) { // GOOGLE FONTS - Only called on server. $protocol = is_ssl() ? 'https' : 'http'; $query_args = array('family' => $cjtheme_google_fonts_string); wp_enqueue_style('cjtheme-google-fonts', add_query_arg($query_args, "{$protocol}://fonts.googleapis.com/css"), array(), null); } // Custom calls as per item_setup $cjtheme_frontend_scripts = cjtheme_item_vars('frontend_scripts'); $cjtheme_frontend_styles = cjtheme_item_vars('frontend_styles'); if (is_null($cjtheme_frontend_scripts)) { die('Frontend scripts item variables not defined in item_setup.php'); } else { foreach ($cjtheme_frontend_scripts as $handle => $vars) { $location_dir = $theme_dir . '/' . $vars[1] . $vars[0]; $location_url = $theme_url . '/' . $vars[1] . $vars[0]; if (!file_exists($location_dir)) { echo sprintf('<b>%s</b> not found under specified location:<br>%s', $vars[0], $location_dir); die; } else { wp_register_script($handle, $location_url, $vars[2], $vars[3], $vars[4]); wp_enqueue_script($handle); } } } if (is_null($cjtheme_frontend_styles)) { die('Frontend scripts item variables not defined in item_setup.php'); } else { foreach ($cjtheme_frontend_styles as $handle => $vars) { $location_dir = $theme_dir . '/' . $vars[1] . $vars[0]; $location_url = $theme_url . '/' . $vars[1] . $vars[0]; if (!file_exists($location_dir)) { echo sprintf('<b>%s</b> not found under specified location:<br>%s', $vars[0], $location_dir); die; } else { wp_register_style($handle, $location_url, $vars[2], $vars[3], $vars[4]); wp_enqueue_style($handle); } } } wp_register_style('theme-dynamic-styles', admin_url('admin-ajax.php') . '?action=cjtheme_dynamic_css', null, time(), 'screen'); // wp_enqueue_style('theme-dynamic-styles'); wp_register_script('theme-dynamic-js', admin_url('admin-ajax.php') . '?action=cjtheme_dynamic_js', array('jquery'), time(), true); // wp_enqueue_script('theme-dynamic-js'); } }
function cjtheme_duplicate_options() { global $cjtheme_file_opts; $duplicates = implode('<br />', array_unique(array_diff_assoc($cjtheme_file_opts, array_unique($cjtheme_file_opts)))); if (!empty($duplicates)) { $display[] = '<div class="error">'; $display[] = sprintf(__('<p><strong>ERROR</strong>: Duplicate options found! <br /><b>%s <br />(%s)</b></p>', 'cjtheme'), cjtheme_item_info('item_name'), cjtheme_item_path('item_dir')); $display[] = '<p>' . $duplicates . '</p>'; $display[] = '</div>'; echo implode('', $display); } }
function cjtheme_assistant_menu_item() { echo '<li class="assistant-menu-item"><a href="#cjtheme-item-assistant" class="toggle-id">Help & Support</a>'; echo '<ul>'; echo '<li class="assistant-menu-item"><a href="' . cjtheme_assistant_url('start-over', cjtheme_callback_url('core_welcome')) . '" class="toggle-id">Setup Assistant</a></li>'; echo '<li><a target="_blank" href="' . cjtheme_item_info('quick_start_guide_url') . '">Quick Start Guide</a></li>'; echo '<li><a target="_blank" href="' . cjtheme_item_info('documentation_url') . '">Documentation</a></li>'; echo '<li><a target="_blank" href="' . cjtheme_item_info('support_forum_url') . '">Support Forum</a></li>'; echo '<li><a target="_blank" href="' . cjtheme_item_info('feature_request_url') . '">Reques new features</a></li>'; echo '<li><a target="_blank" href="' . cjtheme_item_info('report_bugs_url') . '">Report Bugs & Issues</a></li>'; echo '</ul>'; echo '</li>'; }
function cjtheme_show_notification() { $cjtheme_notification_name = sha1('cjtheme_notification_' . site_url()); $cjtheme_notification_value = get_option($cjtheme_notification_name); $cjtheme_notification_timestamp_name = sha1('cjtheme_notification_' . site_url() . 'timestamp'); $cjtheme_notification_timestamp_value = get_option($cjtheme_notification_timestamp_name); if ($cjtheme_notification_value && $cjtheme_notification_timestamp_value['closed'] != 1) { $display[] = '<div id="notification-' . $cjtheme_notification_value->ID . '" class="updated push-notification-message">'; $display[] = '<div class="notification-icon">'; $display[] = '<img src="http://cssjockey.com/files/leaf-64.png" />'; $display[] = '</div>'; $display[] = '<div class="notification-content">'; $display[] = '<h3 style="margin:0 0 10px 0;">' . cjtheme_item_info('item_name') . '</h3>'; $display[] = '<p style="font-size:14px; margin:0 0 0 0;"><b>' . $cjtheme_notification_value->title . '</b><i style="color: #999;"> ~ ' . $cjtheme_notification_value->dated . '</i></p>'; $display[] = '<div style="padding-right:50px;">' . $cjtheme_notification_value->content . '</div>'; $display[] = '</div>'; $display[] = '<a href="#notification-' . $cjtheme_notification_value->ID . '" data-id="' . $cjtheme_notification_value->ID . '" class="notification-close">x</a>'; $display[] = '</div>'; echo implode('', $display); } }
<?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> ' . __('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> ' . __('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> ' . __('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(' • ', $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');
/** * @package CSSJockey WordPress Framework * @author Mohit Aneja (cssjockey.com) * @version FW-20150208 */ if (!isset($cjtheme_item_vars['localize_variables'])) { echo '<div class="margin-25-top margin-15-right">'; echo cjtheme_show_message('error', __('Dropdown key language strings not found in item_setup.php. Specify an array $cjtheme_item_vars["localize_variables"]', 'cjtheme')); echo '</div>'; die; } ?> <div class="wrap"> <h2><?php echo sprintf(__('%s Settings', 'cjtheme'), ucwords(cjtheme_item_info('item_name'))); ?> </h2> <nav class="cjtheme-dropdown clearfix"> <ul> <li class="home"><a href="<?php echo cjtheme_callback_url('core_welcome'); ?> " title=""><i class="fa fa-home"></i></a> <ul> <!-- <li><a href="<?php echo cjtheme_callback_url('core_maintenance_mode'); ?> "><?php _e('Maintenance Mode', 'cjtheme');
function cjtheme_callback_url($callback = null) { $text_domain = cjtheme_item_info('text_domain'); $callback = isset($_GET['callback']) && is_null($callback) ? $_GET['callback'] : $callback; if (!is_null($callback)) { return admin_url('admin.php?page=') . cjtheme_item_info('page_slug') . '&callback=' . $callback; } else { return admin_url('admin.php?page=') . cjtheme_item_info('page_slug'); } }
<?php global $current_user; get_currentuserinfo(); $user_info = cjtheme_user_info($current_user->ID); $item_name = cjtheme_item_info('item_name'); $item_type = cjtheme_item_info('item_type'); $quick_setup_quide_link = '<a href="' . cjtheme_item_info('quick_start_guide_url') . '" target="_blank">Quick Start Guide</a>'; $menu_icon = '<img src="' . cjtheme_item_path('framework_url') . '/assets/admin/img/menu-icon.png" width="16" />'; $welcome_msg = <<<EOF <p> <b>Hello {$user_info['display_name']}</b>,<br> Thank you for using our {$item_name} WordPress plugin. </p> <p> I am here to assist you setting up this plugin on your website and I'll also show you some awesome features that comes with this plugin. </p> <p> If you like, you can also check out our {$quick_setup_quide_link} to setup this pugin and learn more about the features. </p> EOF; $end_tour_msg = <<<EOF <p> <b>Thank You, {$user_info['display_name']}</b>,<br> </p> <p> Its been nice interacting with you. In case you need me again,<br> you can call me from <b>Help & Support</b> menu from the navigation on plugin settigns page. </p> <p> Here are a few useful links for further help and contact with CSSJockey team. </p>
<?php require 'theme-update-checker.php'; $item_info = cjtheme_item_info(); $cjtheme_eon = sha1('cjtheme_verify_epc' . site_url()); $cjtheme_eov = get_option($cjtheme_eon); $cjtheme_upgrade_url = 'http://api.cssjockey.com/?cj_action=upgrades&item_id=' . $item_info['item_id'] . '&item_type=' . $item_info['item_type'] . '&purchase_code=' . $cjtheme_eov . '&slug=' . basename(cjtheme_item_path('item_dir')) . '&site_url=' . site_url(); $theme_slug = basename(get_template_directory_uri()); $theme_update_checker = new ThemeUpdateChecker($theme_slug, $cjtheme_upgrade_url);
$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>';
<?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>';
function cjtheme_verify_epcp() { global $wpdb, $current_user; $cjtheme_eon = sha1('cjtheme_verify_epc' . site_url()); $cjtheme_eov = get_option($cjtheme_eon); $item_info = cjtheme_item_info(); $cssjockey_api_url = 'http://api.cssjockey.com/'; $errors = null; $success = null; $error_msg = null; $success_msg = null; // Handle local install if (isset($_POST['cjtheme_verify_purchase_code'])) { if ($_POST['cjtheme_purchase_code'] == '') { $errors[] = __('Please enter purchase code for this product.', 'cjtheme'); } if (is_null($errors)) { $pdata = array('cj_action' => 'verify_envato_code', 'purchase_code' => $_POST['cjtheme_purchase_code'], 'item_id' => $item_info['item_id'], 'textdomain' => $item_info['page_slug'], 'site_url' => site_url()); $response = wp_remote_post($cssjockey_api_url, array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => $pdata, 'cookies' => array())); if (is_wp_error($response)) { $error_message = $response->get_error_message(); $errors[] = $error_message; } else { $result = json_decode($response['body']); if (isset($result->success)) { update_option($cjtheme_eon, $_POST['cjtheme_purchase_code']); $location = cjtheme_callback_url('core_welcome'); wp_redirect($location); exit; } if (isset($result->error)) { $errors['envato'] = $result->error; } } } if (!is_null($errors)) { $error_msg = '<p class="red">' . implode('<br>', $errors) . '</p>'; } } if (!cjtheme_is_local() && cjtheme_item_info('item_id') != 'NA') { $display[] = '<div id="verify-purchase-code" class="updated push-notification-message">'; $display[] = '<div class="notification-icon">'; $display[] = '<img src="http://api.cssjockey.com/files/leaf-64.png" />'; $display[] = '</div>'; $display[] = '<div class="notification-content">'; $display[] = '<h3 style="margin:0 0 10px 0; line-height:1;">' . $item_info['item_name'] . '</h3>'; $display[] = $success_msg; $display[] = '<p>' . sprintf(__('Verify purchase code to enable automatic upgrades and use this %s on this installation.', 'cjtheme'), $item_info['item_type']) . '</p>'; $display[] = '<form action="" method="post">'; $display[] = $error_msg; $display[] = '<p><input name="cjtheme_purchase_code" type="text" value="' . cjtheme_post_default('cjtheme_purchase_code', '') . '" class="verify-input" /></p>'; $display[] = '<p>'; $display[] = '<button name="cjtheme_verify_purchase_code" class="button-primary" style="margin-right:10px;" type="submit">' . __('Verify & Activate License', 'cjtheme') . '</button>'; $display[] = sprintf(__('<a target="_blank" href="%s">Where can I find my Purchase Code?</a>', 'cjtheme'), 'https://help.market.envato.com/hc/en-us/articles/202822600-Where-can-I-find-my-Purchase-Code-'); $display[] = '</p>'; $display[] = '</form>'; $display[] = '</div>'; $display[] = '</div>'; } else { $display[] = ''; } if ($cjtheme_eov == '') { echo implode(null, $display); } }
function cjtheme_shortcode_generator_run(array $meta_boxes) { global $shortcode_tags; // Start with an underscore to hide fields from custom fields list $prefix = '_'; $default_post_types = array('post', 'page'); $custom_post_types = get_post_types(); if (!empty($custom_post_types)) { $custom_post_types = @array_keys($custom_post_types); if (is_array($custom_post_types)) { $show_metabox_on = array_merge($custom_post_types, $default_post_types); } else { $show_metabox_on = $default_post_types; } } else { $show_metabox_on = $default_post_types; } $cjtheme_shortcodes['cjtheme'][] = array('name' => __('Select shortcode', 'cjtheme'), 'value' => 'select shortcode'); if (!empty($shortcode_tags)) { $text_domain_count = strlen('cjtheme'); foreach ($shortcode_tags as $key => $value) { if (!is_array($value) && substr($value, 0, $text_domain_count) == 'cjtheme') { $name = str_replace('cjtheme' . '_', '', $value); $name = str_replace('_', ' ', $name); $cjtheme_shortcodes['cjtheme'][] = array('name' => ucwords($name), 'value' => $value); $shortcode_options[$key] = unserialize(cjtheme_do_shortcode('[' . $key . ' return="defaults"]')); //$shortcode_options[$key] = unserialize(get_option( sha1($key) )); } } } $shortcode_options_display[] = '<span id="cjtheme-shortcode-content" onclick="selectText(\'cjtheme-shortcode-content\')" class="cjtheme-shortcode-content">' . __('Select shortcode', 'cjtheme') . '</span>'; if (isset($shortcode_options) && is_array($shortcode_options)) { foreach ($shortcode_options as $key => $value) { $shortcode_options_display[] = '<span style="clear:both;"></span><div id="' . $key . '" style="clear:both; overflow:hidden; height:0px;" class="cjtheme-shortcode-panel clearfix" data-stype="' . $value['stype'] . '">'; $shortcode_options_display[] = '<b style="border-bottom:1px solid #ddd; display:block; margin-bottom:5px; padding-bottom:5px;">' . ucwords(str_replace('cjtheme', '', str_replace('_', ' ', $key)) . ' ' . __('Options', 'cjtheme')) . '</b>'; if (is_array($value)) { foreach ($value as $skey => $sval) { if ($skey != 'stype' && $sval[1] == 'text') { $shortcode_options_display[] = '<p>'; $shortcode_options_display[] = '<label><b>' . $sval[0] . '</b><br />'; $shortcode_options_display[] = '<input class="' . $key . '-cjtheme-options" data-attr="' . $skey . '" name="cjtheme-' . $skey . '" type="' . $sval[1] . '" value="' . $sval[2] . '" />'; $shortcode_options_display[] = '</label>'; $shortcode_options_display[] = '</p>'; } if ($skey != 'stype' && $sval[1] == 'textarea') { $shortcode_options_display[] = '<p>'; $shortcode_options_display[] = '<label><b>' . $sval[0] . '</b><br />'; $shortcode_options_display[] = '<textarea class="' . $key . '-cjtheme-options" rows="3" cols="40" data-attr="' . $skey . '" name="cjtheme-' . $skey . '">' . $sval[2] . '</textarea>'; $shortcode_options_display[] = '</label>'; $shortcode_options_display[] = '</p>'; } if ($skey != 'stype' && $sval[1] == 'heading') { $shortcode_options_display[] = '<b style="clear:both; border-bottom:1px solid #ddd; display:block; margin-top:15px; margin-bottom:15px; padding-bottom:5px;">'; $shortcode_options_display[] = $sval[0]; $shortcode_options_display[] = '</b>'; } if ($skey != 'stype' && $sval[1] == 'info') { $shortcode_options_display[] = '<div style="clear:both; display:block; margin-top:15px; margin-bottom:15px;">'; $shortcode_options_display[] = $sval[0]; $shortcode_options_display[] = '</div>'; } if ($skey != 'stype' && $sval[1] == 'select' || $sval[1] == 'dropdown') { $shortcode_options_display[] = '<p>'; $shortcode_options_display[] = '<label><b>' . $sval[0] . '</b><br />'; $shortcode_options_display[] = '<select class="' . $key . '-cjtheme-options chzn-select-no-results" data-attr="' . $skey . '" name="cjtheme-' . $skey . '" style="width:250px !important;">'; $opts = ''; $opts = '<option value="">' . __('Please Select ', 'cjtheme') . '</option>'; if (is_array($sval[2])) { $shortcode_options_display[] = $opts; foreach ($sval[2] as $okey => $oval) { $ovalue = str_replace('_', ' ', $oval); $ovalue = str_replace('-', ' ', $ovalue); $shortcode_options_display[] = '<option value="' . $okey . '">' . $ovalue . '</option>'; } } $shortcode_options_display[] = '</select>'; $shortcode_options_display[] = '</label>'; $shortcode_options_display[] = '</p>'; } if ($skey != 'stype' && $sval[1] == 'multiselect' || $sval[1] == 'multidropdown') { $shortcode_options_display[] = '<p>'; $shortcode_options_display[] = '<label><b>' . $sval[0] . '</b><br />'; $shortcode_options_display[] = '<select multiple class="' . $key . '-cjtheme-options chzn-select-no-results" data-attr="' . $skey . '" name="cjtheme-' . $skey . '" style="width:250px !important;">'; $opts = ''; $opts = '<option value="">' . __('Please Select ', 'cjtheme') . '</option>'; if (is_array($sval[2])) { $shortcode_options_display[] = $opts; foreach ($sval[2] as $okey => $oval) { $ovalue = str_replace('_', ' ', $oval); $ovalue = str_replace('-', ' ', $ovalue); $shortcode_options_display[] = '<option value="' . $okey . '">' . $ovalue . '</option>'; } } $shortcode_options_display[] = '</select>'; $shortcode_options_display[] = '</label>'; $shortcode_options_display[] = '</p>'; } } $shortcode_options_display[] = '<br style="clear:both; height:1px;"><br />'; } $shortcode_options_display[] = '</div>'; } } $shortcode_options_panel = implode('', $shortcode_options_display); if (isset($_GET['post'])) { update_post_meta(@$_GET['post'], '_shortcodes', ''); } if (count($cjtheme_shortcodes['cjtheme']) > 1) { $meta_boxes['cjtheme'] = array('id' => 'cjtheme_shortcode_generator', 'title' => sprintf(__('Shortcode Generator (%s)', 'cjtheme'), cjtheme_item_info('item_name')), 'pages' => $show_metabox_on, 'context' => 'advanced', 'priority' => 'high', 'show_names' => false, 'fields' => array(array('name' => __('Choose a shortcode', 'cjtheme'), 'desc' => $shortcode_options_panel, 'id' => $prefix . 'cjtheme_shortcodes', 'type' => 'select', 'options' => $cjtheme_shortcodes['cjtheme'], 'std' => ''))); } return $meta_boxes; }
$display[] = '<select ' . $params . ' class="chzn-select-no-results" name="' . $option['id'] . '[bg_position]" id="' . sanitize_title($option['id']) . '">'; $display[] = implode('', $opts); $display[] = '</select>'; $display[] = '</label>'; $display[] = '</div>'; $display[] = '</div><!-- /clearfix -->'; $display[] = '<div class="cj-info">' . __($option['info'], 'cjtheme') . '</div>'; $display[] = '</td>'; $display[] = '</tr>'; } if ($option['type'] == 'submit') { $display[] = '<tr class="cj-submit"><td class="cj-label"> </td>'; $display[] = '<td class="cj-panel">'; $display[] = '<input ' . $params . ' type="hidden" name="form_message" value="' . $option['default'] . '" />'; $display[] = '<input ' . $params . ' type="submit" id="' . $form_submit . '" name="' . $form_submit . '" value="' . __($option['label'], 'cjtheme') . '" class="button-primary" />' . $option['suffix']; $display[] = '</td>'; $display[] = '</tr>'; } if ($option['type'] == 'submit-full') { $display[] = '<tr class="cj-submit">'; $display[] = '<td colspan="2" class="cj-panel">'; $display[] = '<input ' . $params . ' type="hidden" name="form_message" value="' . $option['default'] . '" />'; $display[] = '<input ' . $params . ' type="submit" id="' . $form_submit . '" name="' . $form_submit . '" value="' . __($option['label'], 'cjtheme') . '" class="button-primary" />' . $option['suffix']; $display[] = '</td>'; $display[] = '</tr>'; } } $display[] = '</table>'; echo '<form action="' . admin_url('admin.php?page=' . cjtheme_item_info('page_slug') . '&callback=' . @$_GET['callback'] . '') . '" method="post" enctype="multipart/form-data">'; echo implode('', $display); echo '</form>';