Exemple #1
0
/**
* Settings
* Creates a custom page for a page
* @since 0.1.0
*/
function ls_remote_create_module_page()
{
    $nonce = $_POST['nonce'];
    $page_id = false;
    // check to see if the submitted nonce matches with the
    // generated nonce we created earlier
    if (!wp_verify_nonce($nonce, 'module-page')) {
        die('Unauthorized attempt');
    }
    $page_title = $_POST['page_title'];
    $page_content = $_POST['page_content'];
    $module_name = $_POST['module_name'];
    if (isset($page_title) && isset($page_content) && isset($module_name)) {
        $helpers = new ls_helpers();
        $page_id = $helpers->add_wp_page($page_title, $page_content);
        if ($page_id) {
            ls_set_settings(array('modules' => array($module_name => array('custom_page_id' => $page_id))));
        }
    }
    header("Content-Type: application/json");
    echo json_encode($page_id);
    exit;
}