/** * Create a new page with the title passed via $_REQUEST */ public static function create_page() { $title = !empty($_REQUEST['title']) ? $_REQUEST['title'] : ''; $response = array(); if ($title) { $args = array('post_type' => 'page', 'post_title' => $title, 'post_status' => 'publish'); $page_id = wp_insert_post($args); $response['page'] = get_page($page_id); $html = learn_press_pages_dropdown('', '', array('echo' => false)); preg_match_all('!value=\\"([0-9]+)\\"!', $html, $matches); $response['ordering'] = $matches[1]; $response['html'] = '<a href="' . get_edit_post_link($page_id) . '" target="_blank">' . __('Edit Page', 'learn_press') . '</a> '; $response['html'] .= '<a href="' . get_permalink($page_id) . '" target="_blank">' . __('View Page', 'learn_press') . '</a>'; } else { $response['error'] = __('Page name is empty!', 'learn_press'); } wp_send_json($response); die; }
foreach ($this->get_settings() as $field) { ?> <?php $this->output_field($field); ?> <?php } ?> <?php if (1 == 0) { ?> <tr> <th scope="row"><label><?php _e('Profile page', 'learn_press'); ?> </label></th> <td> <?php $profile_page_id = $settings->get('profile_page_id', 0); learn_press_pages_dropdown($this->get_field_name("profile_page_id"), $profile_page_id); ?> </td> </tr> <?php } ?> <?php do_action('learn_press_after_' . $this->id . '_settings_fields', $this); ?> </tbody> </table>
function output_section_general() { $settings = LPR_Admin_Settings::instance('pages'); $dropdown_pages = learn_press_pages_dropdown('{NAME}', $settings->get('general.courses_page_id', 0), array('id' => '{ID}', 'before' => array('add_new_page' => __('[ Add a new page ]', 'learn_press')), 'class' => 'lpr-dropdown-pages', 'echo' => false)); ?> <h3 class=""><?php echo $this->section['text']; ?> </h3> <table class="form-table"> <tbody> <?php do_action('learn_press_before_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings); ?> <tr> <th scope="row"><label><?php _e('Courses Page', 'learn_press'); ?> </label></th> <td> <?php $page_id = $settings->get('general.courses_page_id', 0); ?> <?php echo preg_replace(array('!{NAME}!', '!{ID}!'), array("lpr_settings[" . $this->id . "][courses_page_id]", 'lpr_courses_page_id'), $dropdown_pages); ?> <p id="lpr_course_page_id_form" class="lpr-quick-add-page-inline hide-if-js"> <input type="text" /> <button class="button" type="button"><?php _e('Ok', 'learn_press'); ?> </button> <a href=""><?php _e('Cancel', 'learn_press'); ?> </a> </p> <p class="lpr-quick-actions-inline<?php echo $page_id ? '' : ' hide-if-js'; ?> "> <a href="<?php echo get_edit_post_link($page_id); ?> " target="_blank"><?php _e('Edit Page', 'learn_press'); ?> </a> <a href="<?php echo get_permalink($page_id); ?> " target="_blank"><?php _e('View Page', 'learn_press'); ?> </a> </p> </td> </tr> <!-- <tr> <th scope="row"><label><?php _e('Profile Page', 'learn_press'); ?> </label></th> <td> <?php learn_press_pages_dropdown("lpr_settings[" . $this->id . "][profile_page_id]", $settings->get('general.profile_page_id', 0)); ?> <?php if ($page_id = $settings->get('general.profile_page_id', 0)) { ?> <a href="<?php echo get_edit_post_link($page_id); ?> " target="_blank"><?php _e('Edit Page', 'learn_press'); ?> </a> <a href="<?php echo get_permalink($page_id); ?> " target="_blank"><?php _e('View Page', 'learn_press'); ?> </a> <?php } ?> </td> </tr> --> <tr> <th scope="row"><label><?php _e('Take Course Confirm', 'learn_press'); ?> </label></th> <td> <?php $page_id = $settings->get('general.taken_course_confirm_page_id', 0); $output = preg_replace(array('!{NAME}!', '!{ID}!'), array("lpr_settings[" . $this->id . "][taken_course_confirm_page_id]", 'lpr_taken_course_confirm_page_id'), $dropdown_pages); $output = preg_replace('!selected="selected"!', '', $output); $output = preg_replace('!(value="' . $page_id . '")!', '$1 selected="selected"', $output); echo $output; ?> <?php //learn_press_pages_dropdown( "lpr_settings[" . $this->id . "][taken_course_confirm_page_id]", $settings->get('general.taken_course_confirm_page_id', 0)); ?> <p class="lpr-quick-add-page-inline hide-if-js"> <input type="text" /> <button class="button" type="button"><?php _e('Ok', 'learn_press'); ?> </button> <a href=""><?php _e('Cancel', 'learn_press'); ?> </a> </p> <p class="lpr-quick-actions-inline<?php echo $page_id ? '' : ' hide-if-js'; ?> "> <a href="<?php echo get_edit_post_link($page_id); ?> " target="_blank"><?php _e('Edit Page', 'learn_press'); ?> </a> <a href="<?php echo get_permalink($page_id); ?> " target="_blank"><?php _e('View Page', 'learn_press'); ?> </a> </p> </td> </tr> <tr> <th scope="row"><label><?php _e('Become a Teacher', 'learn_press'); ?> </label></th> <td> <?php $page_id = $settings->get('general.become_teacher_form_page_id', 0); $output = preg_replace(array('!{NAME}!', '!{ID}!'), array("lpr_settings[" . $this->id . "][become_teacher_form_page_id]", 'lpr_become_teacher_form_page_id'), $dropdown_pages); $output = preg_replace('!selected="selected"!', '', $output); $output = preg_replace('!(value="' . $page_id . '")!', '$1 selected="selected"', $output); echo $output; ?> <p class="lpr-quick-add-page-inline hide-if-js"> <input type="text" /> <button class="button" type="button"><?php _e('Ok', 'learn_press'); ?> </button> <a href=""><?php _e('Cancel', 'learn_press'); ?> </a> </p> <p class="lpr-quick-actions-inline<?php echo $page_id ? '' : ' hide-if-js'; ?> "> <a href="<?php echo get_edit_post_link($page_id); ?> " target="_blank"><?php _e('Edit Page', 'learn_press'); ?> </a> <a href="<?php echo get_permalink($page_id); ?> " target="_blank"><?php _e('View Page', 'learn_press'); ?> </a> </p> </td> </tr> <?php do_action('learn_press_after_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings); ?> </tbody> </table> <?php }
$this->output_field($field); ?> <?php } ?> <?php if (1 == 0) { ?> <tr> <th scope="row"><label><?php _e('Courses Page', 'learn_press'); ?> </label></th> <td> <?php learn_press_pages_dropdown($this->get_field_name("courses_page_id"), $courses_page_id); ?> </td> </tr> <tr> <th scope="row"><label><?php _e('Course category base', 'learn_press'); ?> </label></th> <td> <input type="text" class="regular-text" name="<?php echo $this->get_field_name("course_category_base"); ?> " value="<?php echo $settings->get('course_category_base'); ?>
<tr> <th scope="row" class="titledesc"><?php echo esc_html($options['title']); ?> </th> <td> <?php learn_press_pages_dropdown($options['id'], $this->get_option($options['id'], $options['default'])); ?> </td> </tr>
<td> <?php $cart_page_id = $settings->get('cart_page_id', 0); learn_press_pages_dropdown($this->get_field_name("cart_page_id"), $cart_page_id); ?> </td> </tr> <tr> <th scope="row"><label><?php _e('Checkout page', 'learn_press'); ?> </label></th> <td> <?php $checkout_page_id = $settings->get('checkout_page_id', 0); learn_press_pages_dropdown($this->get_field_name("checkout_page_id"), $checkout_page_id); ?> </td> </tr> <?php } ?> </tbody> </table> <?php if (1 == 0) { ?> <h3><?php _e('Checkout Endpoints', 'learn_press'); ?>
</tr> --> <tr> <th scope="row"><label><?php _e('Take Course Confirm', 'learn_press'); ?> </label></th> <td> <?php $taken_course_confirm_page_id = $settings->get('taken_course_confirm_page_id', 0); learn_press_pages_dropdown($this->get_field_name("taken_course_confirm_page_id"), $taken_course_confirm_page_id); ?> </td> </tr> <tr> <th scope="row"><label><?php _e('Become a Teacher', 'learn_press'); ?> </label></th> <td> <?php $become_teacher_form_page_id = $settings->get('become_teacher_form_page_id', 0); learn_press_pages_dropdown($this->get_field_name("become_teacher_form_page_id"), $become_teacher_form_page_id); ?> </td> </tr> <?php do_action('learn_press_after_' . $this->id . '_' . $this->section['id'] . '_settings_fields', $settings); ?> </tbody> </table>