Example #1
0
/**
 * Editor callback form submit.
 */
function wpcf_fields_numeric_editor_submit()
{
    $add = '';
    if (!empty($_POST['format'])) {
        $add .= ' format="' . strval($_POST['format']) . '"';
    }
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (!empty($field)) {
        $shortcode = wpcf_fields_get_shortcode($field, $add);
        wpcf_admin_fields_save_field_last_settings($_GET['field_id'], array('format' => $_POST['format']));
        echo editor_admin_popup_insert_shortcode_js($shortcode);
        die;
    }
}
Example #2
0
/**
 * Editor callback form submit.
 */
function wpcf_fields_email_editor_submit()
{
    $add = '';
    if (!empty($_POST['title'])) {
        $add = ' title="' . strval($_POST['title']) . '"';
    }
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (!empty($field)) {
        $shortcode = wpcf_fields_get_shortcode($field, $add);
        wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
        echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
        die;
    }
}
/**
 * Editor callback form submit.
 */
function wpcf_fields_image_editor_submit($data, $field, $context)
{
    // Saved settings
    $settings = array();
    $add = '';
    if (!empty($data['alt'])) {
        $add .= ' alt="' . strval($data['alt']) . '"';
    }
    if (!empty($data['title'])) {
        $add .= ' title="' . strval($data['title']) . '"';
    }
    $size = !empty($data['image_size']) ? $data['image_size'] : false;
    if ($size == 'wpcf-custom') {
        if (!empty($data['width'])) {
            $add .= ' width="' . intval($data['width']) . '"';
        }
        if (!empty($data['height'])) {
            $add .= ' height="' . intval($data['height']) . '"';
        }
    } else {
        if (!empty($size)) {
            $add .= ' size="' . $size . '"';
            $settings['image_size'] = $size;
        }
    }
    if (!empty($data['alignment'])) {
        $add .= ' align="' . $data['alignment'] . '"';
        $settings['alignment'] = $data['alignment'];
    }
    if (!empty($data['url'])) {
        $add .= ' url="true"';
    }
    if (!empty($data['onload'])) {
        $add .= ' onload="' . $data['onload'] . '"';
    }
    if (array_key_exists('image_size', $data) && $data['image_size'] != 'full') {
        if (!empty($data['proportional'])) {
            $settings['resize'] = isset($data['resize']) ? $data['resize'] : 'proportional';
            $add .= " resize=\"{$settings['resize']}\"";
            if ($settings['resize'] == 'pad') {
                if (isset($data['padding_transparent'])) {
                    $data['padding_color'] = 'transparent';
                }
                if (empty($data['padding_color'])) {
                    $data['padding_color'] = '#FFF';
                }
                if ((strpos($data['padding_color'], '#') !== 0 || !(strlen($data['padding_color']) == 4 || strlen($data['padding_color']) == 7)) && $data['padding_color'] != 'transparent') {
                    $data['padding_color'] = '#FFF';
                }
                $settings['padding_color'] = $data['padding_color'];
                $add .= " padding_color=\"{$data['padding_color']}\"";
            }
        } else {
            if (!isset($data['raw_mode'])) {
                $settings['resize'] = 'stretch';
                $add .= ' resize="stretch"';
            }
        }
    }
    $field = apply_filters('wpcf_fields_image_editor_submit_field', $field);
    // Save settings
    wpcf_admin_fields_save_field_last_settings($field['id'], $settings);
    if ($context == 'usermeta') {
        $add .= wpcf_get_usermeta_form_addon_submit();
        $shortcode = wpcf_usermeta_get_shortcode($field, $add);
    } elseif ($context == 'termmeta') {
        $add .= wpcf_get_termmeta_form_addon_submit();
        $shortcode = wpcf_termmeta_get_shortcode($field, $add);
    } else {
        $shortcode = wpcf_fields_get_shortcode($field, $add);
    }
    return $shortcode;
}
Example #4
0
/**
 * Processes editor popup submit
 */
function wpcf_fields_google_map_editor_submit()
{
    // Get field
    $field = wpcf_admin_fields_get_field(strval($_GET['field_id']));
    if (!empty($field)) {
        $add = '';
        // Add parameters
        if (!empty($_POST['width'])) {
            $add .= ' width="' . strval($_POST['width']) . '"';
        }
        if (!empty($_POST['height'])) {
            $add .= ' height="' . strval($_POST['height']) . '"';
        }
        // Generate shortcode
        $shortcode = wpcf_fields_get_shortcode($field, $add);
        // Save settings
        wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
        // Trigger inserting shortcode in parent editor
        echo editor_admin_popup_insert_shortcode_js($shortcode);
    }
    die;
}
Example #5
0
/**
 * Editor callback form submit.
 */
function wpcf_fields_file_editor_submit()
{
    $add = '';
    if (!empty($_POST['link'])) {
        $add .= ' link="true"';
        if (!empty($_POST['title'])) {
            $add .= ' title="' . strval($_POST['title']) . '"';
        }
    }
    if (!empty($_POST['class'])) {
        $add .= ' class="' . $_POST['class'] . '"';
    }
    if (!empty($_POST['style'])) {
        $add .= ' style="' . $_POST['style'] . '"';
    }
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (!empty($field)) {
        $shortcode = wpcf_fields_get_shortcode($field, $add);
        wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
        echo editor_admin_popup_insert_shortcode_js($shortcode);
        die;
    }
}
Example #6
0
/**
 * Inserts shortcode in editor.
 * 
 * @return type 
 */
function wpcf_fields_date_editor_form_submit()
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    if (!isset($_POST['wpcf']['field_id'])) {
        return false;
    }
    $field = wpcf_admin_fields_get_field($_POST['wpcf']['field_id']);
    if (empty($field)) {
        return false;
    }
    $add = ' ';
    $style = isset($_POST['wpcf']['style']) ? $_POST['wpcf']['style'] : 'text';
    $add .= 'style="' . $style . '"';
    $format = '';
    if ($style == 'text') {
        if ($_POST['wpcf']['format'] == 'custom') {
            $format = $_POST['wpcf']['format-custom'];
        } else {
            $format = $_POST['wpcf']['format'];
        }
        if (empty($format)) {
            $format = get_option('date_format');
        }
        $add .= ' format="' . $format . '"';
    }
    $shortcode = wpcf_fields_get_shortcode($field, $add);
    wpcf_admin_fields_save_field_last_settings($_POST['wpcf']['field_id'], array('style' => $style, 'format' => $_POST['wpcf']['format'], 'format-custom' => $_POST['wpcf']['format-custom']));
    echo editor_admin_popup_insert_shortcode_js($shortcode);
    die;
}
Example #7
0
/**
 * Editor callback form submit.
 */
function wpcf_fields_image_editor_submit()
{
    $add = '';
    if (!empty($_POST['alt'])) {
        $add .= ' alt="' . strval($_POST['alt']) . '"';
    }
    if (!empty($_POST['title'])) {
        $add .= ' title="' . strval($_POST['title']) . '"';
    }
    $size = !empty($_POST['image-size']) ? $_POST['image-size'] : false;
    if ($size == 'wpcf-custom') {
        if (!empty($_POST['width'])) {
            $add .= ' width="' . intval($_POST['width']) . '"';
        }
        if (!empty($_POST['height'])) {
            $add .= ' height="' . intval($_POST['height']) . '"';
        }
        if (!empty($_POST['proportional'])) {
            $add .= ' proportional="true"';
        }
    } else {
        if (!empty($size)) {
            $add .= ' size="' . $size . '"';
        }
    }
    if (!empty($_POST['alignment'])) {
        $add .= ' align="' . $_POST['alignment'] . '"';
    }
    $field = wpcf_admin_fields_get_field($_GET['field_id']);
    if (!empty($field)) {
        $shortcode = wpcf_fields_get_shortcode($field, $add);
        wpcf_admin_fields_save_field_last_settings($_GET['field_id'], $_POST);
        echo wpcf_admin_fields_popup_insert_shortcode_js($shortcode);
        die;
    }
}