function add_vibe_metaboxes() { $prefix = 'vibe_'; $post_metabox = vibe_meta_box_arrays('post'); $page_metabox = vibe_meta_box_arrays('page'); $course_metabox = vibe_meta_box_arrays('course'); $course_product_metabox = vibe_meta_box_arrays('course_product'); $unit_metabox = vibe_meta_box_arrays('unit'); $question_metabox = vibe_meta_box_arrays('question'); $quiz_metabox = vibe_meta_box_arrays('quiz'); $testimonial_metabox = vibe_meta_box_arrays('testimonial'); $product_metabox = vibe_meta_box_arrays('product'); $wplms_events_metabox = vibe_meta_box_arrays('wplms-event'); $payments_metabox = vibe_meta_box_arrays('payments'); $certificate_metabox = vibe_meta_box_arrays('certificate'); $wplms_assignments_metabox = vibe_meta_box_arrays('wplms-assignment'); $wplms_popup_metabox = vibe_meta_box_arrays('popup'); $dwqna_custom_metabox = array(array('label' => __('Connected Course', 'vibe-customtypes'), 'desc' => __('Connect this question to a course', 'vibe-customtypes'), 'id' => $prefix . 'question_course', 'type' => 'selectcpt', 'post_type' => 'course'), array('label' => __('Connected Unit', 'vibe-customtypes'), 'desc' => __('Connect this question to a Unit', 'vibe-customtypes'), 'id' => $prefix . 'question_unit', 'type' => 'selectcpt', 'post_type' => 'unit')); $post_metabox = new custom_add_meta_box('post-settings', __('Post Settings', 'vibe-customtypes'), $post_metabox, 'post', true); $page_metabox = new custom_add_meta_box('page-settings', __('Page Settings', 'vibe-customtypes'), $page_metabox, 'page', true); $course_box = new custom_add_meta_box('page-settings', __('Course Settings', 'vibe-customtypes'), $course_metabox, 'course', true); $course_product = __('Course Product', 'vibe-customtypes'); if (function_exists('pmpro_getAllLevels')) { $course_product = __('Course Membership', 'vibe-customtypes'); } $course_product_box = new custom_add_meta_box('post-settings', $course_product, $course_product_metabox, 'course', true); $unit_box = new custom_add_meta_box('page-settings', __('Unit Settings', 'vibe-customtypes'), $unit_metabox, 'unit', true); $question_box = new custom_add_meta_box('page-settings', __('Question Settings', 'vibe-customtypes'), $question_metabox, 'question', true); $quiz_box = new custom_add_meta_box('page-settings', __('Quiz Settings', 'vibe-customtypes'), $quiz_metabox, 'quiz', true); if (post_type_exists('dwqa-question')) { $dwqna_custom_box = new custom_add_meta_box('page-settings', __('Settings', 'vibe-customtypes'), $dwqna_custom_metabox, 'dwqa-question', false); } $testimonial_box = new custom_add_meta_box('testimonial-info', __('Testimonial Author Information', 'vibe-customtypes'), $testimonial_metabox, 'testimonials', true); $payments_metabox = new custom_add_meta_box('page-settings', __('Payments Settings', 'vibe-customtypes'), $payments_metabox, 'payments', true); $certificates_metabox = new custom_add_meta_box('page-settings', __('Certificate Template Settings', 'vibe-customtypes'), $certificate_metabox, 'certificate', true); $popup_metabox = new custom_add_meta_box('page-settings', __('Popup Settings', 'vibe-customtypes'), $wplms_popup_metabox, 'popups', true); $surveys_metabox = new custom_add_meta_box('page-settings', __('Survey/Practice Settings', 'vibe-customtypes'), $survey_metabox, 'survey', true); if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) || function_exists('is_plugin_active_for_network') && is_plugin_active_for_network('woocommerce/woocommerce.php')) { $flag = apply_filters('wplms_woocommerce_enable_pricing', 1); if ($flag) { $product_box = new custom_add_meta_box('page-settings', __('Product Course Settings', 'vibe-customtypes'), $product_metabox, 'product', true); } } if (in_array('wplms-events/wplms-events.php', apply_filters('active_plugins', get_option('active_plugins')))) { $events_metabox = new custom_add_meta_box('page-settings', __('WPLMS Events Settings', 'vibe-customtypes'), $wplms_events_metabox, 'wplms-event', true); } if (in_array('wplms-assignments/wplms-assignments.php', apply_filters('active_plugins', get_option('active_plugins')))) { $eassignments_metabox = new custom_add_meta_box('page-settings', __('WPLMS Assignments Settings', 'vibe-customtypes'), $wplms_assignments_metabox, 'wplms-assignment', true); } }
function course_pricing_models($settings) { $product_settings = vibe_meta_box_arrays('course_product'); unset($product_settings['vibe_course_free']); unset($product_settings['vibe_product']); foreach ($product_settings as $key => $prd_set) { if (empty($product_settings[$key]['text'])) { $product_settings[$key]['text'] = $product_settings[$key]['label']; } } if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { array_splice($settings['course_pricing']['fields'], 3, 0, $product_settings); } else { unset($settings['course_pricing']['fields'][2]); array_splice($settings['course_pricing']['fields'], 2, 0, $product_settings); } return $settings; }
function get_sub_element() { $question_id = $_POST['id']; if (!isset($_POST['security']) || !wp_verify_nonce($_POST['security'], 'security') || !current_user_can('edit_posts') || !is_numeric($_POST['id'])) { _e('Security check Failed. Contact Administrator.', 'wplms-front-end'); die; } $post_type = get_post_type($question_id); $settings = vibe_meta_box_arrays($post_type); ?> <div class="<?php echo $post_type; ?> _edit_settings_content"> <div class="list-group-item"> <label><?php _e('Title', 'wplms-front-end'); ?> </label> <input type="text" class="post_field megatext" data-type="post_title" data-id="post_title" placeholder="<?php _e('Enter title', 'wplms-front-end'); ?> " value="<?php echo get_the_title($question_id); ?> " class="form-control no-border" required="" tabindex="0" aria-required="true" aria-invalid="true"> </div> <div class="list-group-item"> <label><?php _e('Content', 'wplms-front-end'); ?> </label> <?php $content = get_post_field('post_content', $question_id); $id_string = $post_type . '__' . rand(0, 999); wp_editor($content, 'post_content_' . $id_string, array('editor_class' => 'post_field')); ?> <script> tinyMCE.execCommand("mceRemoveEditor", true, "<?php echo 'post_content_' . $id_string; ?> "); tinyMCE.execCommand("mceAddEditor", false, "<?php echo 'post_content_' . $id_string; ?> "); quicktags({id : "<?php echo 'post_content_' . $id_string; ?> "}); tinyMCE.triggerSave(); </script> </div> <?php foreach ($settings as $setting) { ?> <div class="list-group-item"><?php WPLMS_Front_End_Fields::generate_fields($setting, $question_id); ?> </div><?php } $buttons = apply_filters('wplms_front_end_element_buttons', array(array('label' => __('SAVE', 'vibe'), 'id' => 'save_element_button', 'data-id' => $question_id, 'type' => 'small_button'), array('label' => __('EDIT IN ADMIN', 'vibe'), 'id' => 'edit_element_button', 'href' => get_edit_post_link($question_id), 'type' => 'small_button'), array('label' => __('PREVIEW & STATS', 'vibe'), 'id' => 'preview_element_button', 'href' => get_permalink($question_id), 'type' => 'small_button'), array('label' => __('Close', 'vibe'), 'id' => 'close_element_button', 'type' => 'small_button'))); foreach ($buttons as $button) { WPLMS_Front_End_Fields::generate_fields($button, $question_id); } ?> </div> <?php die; }
public function get_connected_data($id, $post_type = NULL) { global $wpdb; $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key NOT REGEXP '^[0-9]+\$'", $id), ARRAY_A); foreach ($results as $result) { $data = @unserialize($result['meta_value']); if ($data !== false) { } else { $data = $result['meta_value']; } if (is_array($data)) { foreach ($data as $key => $d) { if (is_array($d)) { $data[$key] = implode(',', $d); } } $comma_saperated = implode('|', $data); $key_label = ''; $label = vibe_meta_box_arrays($post_type); $key_label = $label[$result['meta_key']]['label']; $this->csv[] = array($wpdb->prefix . 'postmeta', $result['post_id'], $result['meta_key'], $key_label, $comma_saperated); } else { $key_label = ''; $label = vibe_meta_box_arrays($post_type); if (is_array($label) && isset($label[$result['meta_key']]['label'])) { $key_label = $label[$result['meta_key']]['label']; } else { $label = str_replace('_', ' ', $result['meta_key']); $key_label = ucfirst($label); } $this->csv[] = array($wpdb->prefix . 'postmeta', $result['post_id'], $result['meta_key'], $key_label, $data); } } }
function course_pricing_models($settings) { $product_settings = vibe_meta_box_arrays('course_product'); unset($product_settings['vibe_course_free']); unset($product_settings['vibe_product']); foreach ($product_settings as $key => $prd_set) { $product_settings[$key]['text'] = $product_settings[$key]['label']; } array_splice($settings['course_pricing']['fields'], 3, 0, $product_settings); return $settings; }