Ejemplo n.º 1
0
function wiziapp_triggerCacheUpdate($option, $oldvalue, $_newvalue)
{
    // Once per request...
    if (strpos($option, '_') !== 0 && strpos($option, 'wiziapp') === FALSE) {
        remove_action('update_option', 'wiziapp_triggerCacheUpdate');
        wiziapp_updateCacheTimestampKey();
    }
}
/**
* Used to update the wiziapp_pages option
* 
* Used by the system control services to defined which pages we are showing where
* 
* POST /wiziapp/system/pages
* 
* @todo add validation to the content of the pages
* 
* @param string screens A json string holding the pages configuration
* 
* @returns regular json status header.
*/
function wiziapp_updatePagesConfiguration()
{
    wiziapp_checkSystemAuth();
    $options = get_option('wiziapp_pages');
    $pagesJson = stripslashes($_POST['pages']);
    $pages = json_decode($pagesJson, TRUE);
    if (!$pages) {
        $status = FALSE;
        $message = __('Unable to decode pages: ', 'wiziapp') . $pagesJson;
    } else {
        if (empty($options)) {
            $options = $pages;
            $status = add_option('wiziapp_pages', $options, '', 'no');
            $message = __('Unable to create pages configuration', 'wiziapp');
        } else {
            $options = $pages;
            $status = update_option('wiziapp_pages', $options);
            $message = __('Unable to update pages configuration', 'wiziapp');
        }
        if ($status) {
            wiziapp_updateCacheTimestampKey();
        }
    }
    $header = array('action' => 'pages', 'status' => $status, 'code' => $status ? 200 : 4004, 'message' => $message);
    echo json_encode(array('header' => $header));
    exit;
}