예제 #1
0
function dl_save_metabox_page_sidebar($post_id, $post)
{
    global $options;
    if (!isset($_POST['dl_metabox_page_sidebar_nonce']) || !wp_verify_nonce($_POST['dl_metabox_page_sidebar_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    /* Check if the current user has permission to edit the post. */
    if (!current_user_can('edit_page', $post_id)) {
        return;
    }
    dl_save_standard('sidebar_title_above', $_POST['sidebar_title_above'], $post_id, 'page', 'text');
    if ($options['advanced_page_sidebar_useeditor_textabove'] == false) {
        dl_save_standard('sidebar_text_above', $_POST['sidebar_text_above'], $post_id, 'page', 'textnohtml');
    } else {
        dl_save_standard('sidebar_text_above', $_POST['sidebar_text_above'], $post_id, 'page', 'wpeditor');
    }
    dl_save_standard('sidebar_title_below', $_POST['sidebar_title_below'], $post_id, 'page', 'text');
    if ($options['advanced_page_sidebar_useeditor_textbelow'] == false) {
        dl_save_standard('sidebar_text_below', $_POST['sidebar_text_below'], $post_id, 'page', 'textnohtml');
    } else {
        dl_save_standard('sidebar_text_below', $_POST['sidebar_text_below'], $post_id, 'page', 'wpeditor');
    }
    $newval = isset($_POST['dlval_sidebar_title_linkblock1']) ? sanitize_text_field($_POST['dlval_sidebar_title_linkblock1']) : 0;
    dl_save_standard('dlval_sidebar_title_linkblock1', $newval, $post_id, 'page', 'text');
    $newval = isset($_POST['dlval_sidebar_title_linkblock2']) ? sanitize_text_field($_POST['dlval_sidebar_title_linkblock2']) : 0;
    dl_save_standard('dlval_sidebar_title_linkblock1', $newval, $post_id, 'page', 'text');
    global $options;
    for ($i = 1; $i <= $options['advanced_page_sidebar_linkblock1_number']; $i++) {
        $name = 'dlval_linkblock1_link' . $i;
        $urlname = $name . '_url';
        $titlename = $name . '_title';
        $oldpageid = get_post_meta($post_id, $name, true);
        $oldurl = get_post_meta($post_id, $urlname, true);
        $oldtitle = get_post_meta($post_id, $titlename, true);
        $c = $i - 1;
        $newurl = isset($_POST[$urlname]) ? esc_url($_POST[$urlname]) : 0;
        $newid = isset($_POST[$name]) ? sanitize_key($_POST[$name]) : 0;
        $newtitle = isset($_POST[$titlename]) ? sanitize_text_field($_POST[$titlename]) : 0;
        if (!isset($newid) || $newid <= 0) {
            // Versuche aus der URL die ID zu ermitteln
            $relativeurl = dl_make_link_relative($newurl);
            if ($relativeurl != $newurl) {
                // Ist eine interne URL, also mnuss es eine ID geben
                $newid = url_to_postid($newurl);
            }
        }
        update_post_meta($post_id, $urlname, $newurl);
        update_post_meta($post_id, $titlename, $newtitle);
        update_post_meta($post_id, $name, $newid);
    }
}
예제 #2
0
function dl_ad_metabox_content_save($post_id)
{
    global $options;
    if ('ad' != get_post_type()) {
        return;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (!isset($_POST['dl_ad_metabox_content_nonce']) || !wp_verify_nonce($_POST['dl_ad_metabox_content_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    if (!current_user_can('edit_page')) {
        return;
    }
    /* Old values */
    $code = get_post_meta($post_id, 'dlval_ad_code', true);
    /* Old values */
    if (empty($code)) {
        $code = get_post_meta($post_id, 'ad_script', true);
    }
    if (empty($targeturl)) {
        $targeturl = get_post_meta($post_id, 'link', true);
    }
    $newval = $_POST['dlval_ad_code'];
    if (!empty($newval)) {
        if (isset($code) && $code != $newval) {
            update_post_meta($post_id, 'dlval_ad_code', $newval);
        } else {
            add_post_meta($post_id, 'dlval_ad_code', $newval, true);
        }
    } elseif ($code) {
        delete_post_meta($post_id, 'dlval_ad_code', $code);
    }
    if (get_post_meta($post_id, 'ad_script', true)) {
        delete_post_meta($post_id, 'ad_script', $code);
    }
    if (filter_var($_POST['dlval_ad_url'], FILTER_VALIDATE_URL)) {
        $newval = $_POST['dlval_ad_url'];
    } else {
        $newval = '';
    }
    dl_save_standard('dlval_ad_url', $newval, $post_id, 'post', 'url');
    $newval = isset($_POST['dlval_ad_notes']) ? sanitize_text_field($_POST['dlval_ad_notes']) : 0;
    dl_save_standard('dlval_ad_notes', $newval, $post_id, 'post', 'text');
    $newval = intval($_POST['dlval_ad_position']);
    dl_save_standard('dlval_ad_position', $newval, $post_id, 'post', 'int');
}
예제 #3
0
function dl_imagelink_metabox_content_save($post_id)
{
    global $options;
    if ('imagelink' != get_post_type()) {
        return;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (!isset($_POST['dl_imagelink_metabox_content_nonce']) || !wp_verify_nonce($_POST['dl_imagelink_metabox_content_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    if ('page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    $newval = isset($_POST['dl_imagelink_desc']) ? sanitize_text_field($_POST['dl_imagelink_desc']) : 0;
    dl_save_standard('portal_description', $newval, $post_id, 'post', 'text');
    $targeturl = get_post_meta($post_id, 'dlval_imagelink_url', true);
    if (filter_var($_POST['dl_imagelink_url'], FILTER_VALIDATE_URL)) {
        $newval = $_POST['dl_imagelink_url'];
    }
    dl_save_standard('dlval_imagelink_url', $newval, $post_id, 'post', 'url');
}