public static function init() { if (is_null(self::$instance)) { self::$instance = new WPLMS_Content_Templates(); } return self::$instance; }
function create_new_question() { if (!isset($_POST['security']) || !wp_verify_nonce($_POST['security'], 'security') || !current_user_can('edit_posts')) { _e('Security check Failed. Contact Administrator.', 'wplms-front-end'); die; } if (empty($_POST['title'])) { _e('Empty title.', 'wplms-front-end'); die; } $template = $_POST['template']; include_once 'class.templates.php'; $settings = WPLMS_Content_Templates::get_template('question', $_POST['template']); if ($_POST['question_tag'] == 'new') { $term = term_exists($_POST['new_question_tag'], 'question-tag'); if ($term !== 0 && $term !== null) { $term_id = $term; } else { $new_term = wp_insert_term($_POST['new_question_tag'], 'question-tag'); $term_id = $new_term['term_id']; } } $args = apply_filters('wplms_front_end_create_question', array('post_type' => 'question', 'post_title' => stripslashes($_POST['title']), 'post_content' => $settings['post_content'], 'post_status' => 'publish', 'tax_input' => array('question-tag' => array($term_id)))); $id = wp_insert_post($args); foreach ($settings['meta_fields'] as $key => $value) { update_post_meta($id, $key, $value); } echo $id; die; }