本文整理汇总了PHP中wpcf_admin_fields_get_field_last_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_fields_get_field_last_settings函数的具体用法?PHP wpcf_admin_fields_get_field_last_settings怎么用?PHP wpcf_admin_fields_get_field_last_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_admin_fields_get_field_last_settings函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_fields_email_editor_callback
/**
* Editor callback form.
*/
function wpcf_fields_email_editor_callback()
{
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
$form = array();
$form['#form']['callback'] = 'wpcf_fields_email_editor_submit';
$form['title'] = array('#type' => 'textfield', '#title' => __('Title', 'wpcf'), '#description' => __('If set, this text will be displayed instead of raw data'), '#name' => 'title', '#value' => isset($last_settings['title']) ? $last_settings['title'] : '');
$form['submit'] = array('#type' => 'markup', '#markup' => get_submit_button());
$f = wpcf_form('wpcf-form', $form);
wpcf_admin_ajax_head('Insert email', 'wpcf');
echo '<form method="post" action="">';
echo $f->renderForm();
echo '</form>';
wpcf_admin_ajax_footer();
}
示例2: wpcf_fields_url_editor_callback
/**
* Editor callback form.
*/
function wpcf_fields_url_editor_callback()
{
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
$form = array();
$form['#form']['callback'] = 'wpcf_fields_url_editor_submit';
$form['title'] = array('#type' => 'textfield', '#title' => __('Title', 'wpcf'), '#description' => __('If set, this text will be displayed instead of raw data'), '#name' => 'title', '#value' => isset($last_settings['title']) ? $last_settings['title'] : '');
$form['class'] = array('#type' => 'textfield', '#title' => __('Class', 'wpcf'), '#name' => 'class', '#value' => isset($last_settings['class']) ? $last_settings['class'] : '');
$form['style'] = array('#type' => 'textfield', '#title' => __('Style', 'wpcf'), '#name' => 'style', '#value' => isset($last_settings['style']) ? $last_settings['style'] : '');
$form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Save Changes'), '#attributes' => array('class' => 'button-primary'));
$f = wpcf_form('wpcf-form', $form);
wpcf_admin_ajax_head('Insert URL', 'wpcf');
echo '<form method="post" action="">';
echo $f->renderForm();
echo '</form>';
wpcf_admin_ajax_footer();
}
示例3: wpcf_fields_google_map_editor_callback
/**
* Adds editor popup callnack.
*
* This form will be showed in editor popup
*/
function wpcf_fields_google_map_editor_callback()
{
wp_enqueue_style('wpcf-fields-google_map', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
wp_enqueue_script('jquery');
// Get field
$field = wpcf_admin_fields_get_field($_GET['field_id']);
if (empty($field)) {
_e('Wrong field specified', 'wpcf');
die;
}
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
if (isset($_POST['_wpnonce_wpcf_form']) && wp_verify_nonce($_POST['_wpnonce_wpcf_form'], 'wpcf-form')) {
add_action('admin_head_wpcf_ajax', 'wpcf_fields_google_map_editor_submit');
}
wpcf_admin_ajax_head(__('Insert Google Map', 'wpcf'));
?>
<form method="post" action="">
<h2><?php
_e('Google Maps');
?>
</h2>
<?php
_e('Specify width and height for Google Map:');
?>
<br /><br />
<?php
wp_nonce_field('wpcf-form', '_wpnonce_wpcf_form');
?>
<input type="text" name="width" value="<?php
echo isset($last_settings['width']) ? $last_settings['width'] : '425';
?>
" />
<br />
<input type="text" name="height" value="<?php
echo isset($last_settings['height']) ? $last_settings['height'] : '350';
?>
" />
<br /><br /><input type="submit" class="button-primary" value="<?php
_e('Insert Google Map');
?>
" />
</form>
<?php
wpcf_admin_ajax_footer();
}
示例4: wpcf_fields_numeric_editor_callback
/**
* Editor callback form.
*/
function wpcf_fields_numeric_editor_callback()
{
wp_enqueue_style('wpcf-fields', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
wp_enqueue_script('jquery');
// Get field
$field = wpcf_admin_fields_get_field($_GET['field_id']);
if (empty($field)) {
_e('Wrong field specified', 'wpcf');
die;
}
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
$form = array();
$form['#form']['callback'] = 'wpcf_fields_numeric_editor_submit';
$form['format'] = array('#type' => 'textfield', '#title' => __('Output format', 'wpcf'), '#description' => __("Similar to sprintf function. Default: 'FIELD_NAME: FIELD_VALUE'.", 'wpcf'), '#name' => 'format', '#value' => isset($last_settings['format']) ? $last_settings['format'] : 'FIELD_NAME: FIELD_VALUE');
$form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Insert shortcode', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
$f = wpcf_form('wpcf-form', $form);
wpcf_admin_ajax_head('Insert numeric', 'wpcf');
echo '<form method="post" action="">';
echo $f->renderForm();
echo '</form>';
}
示例5: wpcf_fields_image_editor_callback
/**
* Editor callback form.
*
* @global object $wpdb
*
*/
function wpcf_fields_image_editor_callback($field, $data, $context, $post)
{
// Get post_ID
$post_ID = !empty($post->ID) ? $post->ID : false;
// Get attachment
$image = false;
$attachment_id = false;
if ($post_ID) {
$image = get_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
if (empty($image)) {
$user_id = wpcf_usermeta_get_user();
$image = get_user_meta($user_id, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
}
if (!empty($image)) {
// Get attachment by guid
global $wpdb;
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $image));
}
}
$data['image'] = $image;
$data['attachment_id'] = $attachment_id;
// Set post type
$post_type = !empty($post->post_type) ? $post->post_type : '';
// Set image_data
$image_data = wpcf_fields_image_get_data($image);
if (!in_array($post_type, array('view', 'view-template'))) {
// We must ignore errors here and treat image as outsider
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 1;
$image_data['is_attachment'] = 0;
}
} else {
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 0;
$image_data['is_attachment'] = 0;
}
}
$data['preview'] = $attachment_id ? wp_get_attachment_image($attachment_id, 'thumbnail') : '';
// Title and Alt
if ($attachment_id) {
$alt = trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true)));
$attachment_post = get_post($attachment_id);
if (!empty($attachment_post)) {
$title = trim(strip_tags($attachment_post->post_title));
} else {
if (!empty($alt)) {
$title = $alt;
}
}
if (empty($alt)) {
$alt = $title;
}
if (!isset($data['title'])) {
$data['title'] = $title;
}
if (!isset($data['alt'])) {
$data['alt'] = $alt;
}
}
// Align options
$data['alignment_options'] = array('none' => __('None', 'wpcf'), 'left' => __('Left', 'wpcf'), 'center' => __('Center', 'wpcf'), 'right' => __('Right', 'wpcf'));
// Remote images settings
$fetch_remote = (bool) wpcf_get_settings('images_remote');
$data['warning_remote'] = false;
if (!types_is_repetitive($field) && $image_data['is_outsider'] && !$fetch_remote && !empty($data['image'])) {
$data['warning_remote'] = true;
}
// Size settings
$data['size_options'] = array('thumbnail' => sprintf(__('Thumbnail - %s', 'wpcf'), get_option('thumbnail_size_w') . 'x' . get_option('thumbnail_size_h')), 'medium' => sprintf(__('Medium - %s', 'wpcf'), get_option('medium_size_w') . 'x' . get_option('medium_size_h')), 'large' => sprintf(__('Large - %s', 'wpcf'), get_option('large_size_w') . 'x' . get_option('large_size_h')), 'full' => __('Original image', 'wpcf'));
$wp_image_sizes = (array) get_intermediate_image_sizes();
foreach ($wp_image_sizes as $wp_size) {
if ($wp_size != 'post-thumbnail' && !array_key_exists($wp_size, $data['size_options'])) {
$data['size_options'][$wp_size] = $wp_size;
}
}
$data['size_options']['wpcf-custom'] = __('Custom size...', 'wpcf');
// Get saved settings
$data = array_merge(wpcf_admin_fields_get_field_last_settings($field['id']), $data);
return array('supports' => array('styling', 'style'), 'tabs' => array('display' => array('menu_title' => __('Display options', 'wpcf'), 'title' => __('Display options for this field:', 'wpcf'), 'content' => WPCF_Loader::template('editor-modal-image', $data))), 'settings' => $data);
}
示例6: wpcf_fields_file_editor_callback
/**
* Editor callback form.
*/
function wpcf_fields_file_editor_callback()
{
wp_enqueue_style('wpcf-fields-file', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
// Get field
$field = wpcf_admin_fields_get_field($_GET['field_id']);
if (empty($field)) {
_e('Wrong field specified', 'wpcf');
die;
}
// Get post_ID
$post_ID = false;
if (isset($_POST['post_id'])) {
$post_ID = intval($_POST['post_id']);
} else {
$http_referer = explode('?', $_SERVER['HTTP_REFERER']);
parse_str($http_referer[1], $http_referer);
if (isset($http_referer['post'])) {
$post_ID = $http_referer['post'];
}
}
// Get attachment
$attachment_id = false;
if ($post_ID) {
$file = get_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
if (!empty($file)) {
// Get attachment by guid
global $wpdb;
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}\r\n WHERE post_type = 'attachment' AND guid=%s", $file));
}
}
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
$form = array();
$form['#form']['callback'] = 'wpcf_fields_file_editor_submit';
if ($attachment_id) {
$form['preview'] = array('#type' => 'markup', '#markup' => '<div class="message updated" style="margin: 0 0 20px 0"><p>' . $file . '</p></div>');
}
$form['link'] = array('#type' => 'checkbox', '#title' => __('Display as link', 'wpcf'), '#name' => 'link', '#default_value' => isset($last_settings['link']) ? $last_settings['link'] : 1);
$form['title'] = array('#type' => 'textfield', '#title' => __('Link title', 'wpcf'), '#name' => 'title', '#value' => isset($last_settings['title']) ? $last_settings['title'] : '');
$form['class'] = array('#type' => 'textfield', '#title' => __('Class', 'wpcf'), '#name' => 'class', '#value' => isset($last_settings['class']) ? $last_settings['class'] : '');
$form['style'] = array('#type' => 'textfield', '#title' => __('Style', 'wpcf'), '#name' => 'style', '#value' => isset($last_settings['style']) ? $last_settings['style'] : '');
$form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Insert shortcode', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
$f = wpcf_form('wpcf-form', $form);
wpcf_admin_ajax_head('Insert email', 'wpcf');
echo '<form method="post" action="">';
echo $f->renderForm();
echo '</form>';
wpcf_admin_ajax_footer();
}
示例7: wpcf_fields_date_editor_callback
/**
* TinyMCE editor form.
*/
function wpcf_fields_date_editor_callback()
{
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
wp_enqueue_script('jquery');
$form = array();
$form['#form']['callback'] = 'wpcf_fields_date_editor_form_submit';
$form['style'] = array('#type' => 'radios', '#name' => 'wpcf[style]', '#options' => array(__('Show as calendar', 'wpcf') => 'calendar', __('Show as text', 'wpcf') => 'text'), '#default_value' => isset($last_settings['style']) ? $last_settings['style'] : 'text', '#after' => '<br />');
$date_formats = apply_filters('date_formats', array(__('F j, Y'), 'Y/m/d', 'm/d/Y', 'd/m/Y'));
$options = array();
foreach ($date_formats as $format) {
$title = date($format, time());
$field['#title'] = $title;
$field['#value'] = $format;
$options[] = $field;
}
$custom_format = isset($last_settings['format-custom']) ? $last_settings['format-custom'] : get_option('date_format');
$options[] = array('#title' => __('Custom', 'wpcf'), '#value' => 'custom', '#suffix' => wpcf_form_simple(array('custom' => array('#name' => 'wpcf[format-custom]', '#type' => 'textfield', '#value' => $custom_format, '#suffix' => ' ' . date($custom_format, time()), '#inline' => true))));
$form['toggle-open'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-toggle" style="display:none;">');
$form['format'] = array('#type' => 'radios', '#name' => 'wpcf[format]', '#options' => $options, '#default_value' => isset($last_settings['format']) ? $last_settings['format'] : get_option('date_format'), '#after' => '<a href="http://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">' . __('Documentation on date and time formatting', 'wpcf') . '</a>');
$form['toggle-close'] = array('#type' => 'markup', '#markup' => '</div>');
$form['field_id'] = array('#type' => 'hidden', '#name' => 'wpcf[field_id]', '#value' => $_GET['field_id']);
$form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => __('Insert date', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
$f = wpcf_form('wpcf-fields-date-editor', $form);
add_action('admin_head_wpcf_ajax', 'wpcf_fields_date_editor_form_script');
wpcf_admin_ajax_head(__('Insert date', 'wpcf'));
echo '<form id="wpcf-form" method="post" action="">';
echo $f->renderForm();
echo '</form>';
wpcf_admin_ajax_footer();
}
示例8: wpcf_fields_image_editor_callback
/**
* Editor callback form.
*/
function wpcf_fields_image_editor_callback()
{
wp_enqueue_style('wpcf-fields-image', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
wp_enqueue_script('jquery');
// Get field
$field = wpcf_admin_fields_get_field($_GET['field_id']);
if (empty($field)) {
_e('Wrong field specified', 'wpcf');
die;
}
// Get post_ID
$post_ID = false;
if (isset($_POST['post_id'])) {
$post_ID = intval($_POST['post_id']);
} else {
$http_referer = explode('?', $_SERVER['HTTP_REFERER']);
if (isset($http_referer[1])) {
parse_str($http_referer[1], $http_referer);
if (isset($http_referer['post'])) {
$post_ID = $http_referer['post'];
}
}
}
// Get attachment
$image = false;
$attachment_id = false;
if ($post_ID) {
$image = get_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
if (!empty($image)) {
// Get attachment by guid
global $wpdb;
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}\r\r\n WHERE post_type = 'attachment' AND guid=%s", $image));
}
}
// Get post type
$post_type = '';
if ($post_ID) {
$post_type = get_post_type($post_ID);
} else {
$http_referer = explode('?', $_SERVER['HTTP_REFERER']);
parse_str($http_referer[1], $http_referer);
if (isset($http_referer['post_type'])) {
$post_type = $http_referer['post_type'];
}
}
$image_data = wpcf_fields_image_get_data($image);
if (!in_array($post_type, array('view', 'view-template'))) {
// We must ignore errors here and treat image as outsider
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 1;
$image_data['is_attachment'] = 0;
}
} else {
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 0;
$image_data['is_attachment'] = 0;
}
}
$last_settings = wpcf_admin_fields_get_field_last_settings($_GET['field_id']);
$form = array();
$form['#form']['callback'] = 'wpcf_fields_image_editor_submit';
if ($attachment_id) {
$form['preview'] = array('#type' => 'markup', '#markup' => '<div style="position:absolute; margin-left:300px;">' . wp_get_attachment_image($attachment_id, 'thumbnail') . '</div>');
}
$alt = '';
$title = '';
if ($attachment_id) {
$alt = trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true)));
$attachment_post = get_post($attachment_id);
if (!empty($attachment_post)) {
$title = trim(strip_tags($attachment_post->post_title));
} else {
if (!empty($alt)) {
$title = $alt;
}
}
if (empty($alt)) {
$alt = $title;
}
}
$form['title'] = array('#type' => 'textfield', '#title' => __('Image title', 'wpcf'), '#description' => __('Title text for the image, e.g. “The Mona Lisa”', 'wpcf'), '#name' => 'title', '#value' => isset($last_settings['title']) ? $last_settings['title'] : $title);
$form['alt'] = array('#type' => 'textfield', '#title' => __('Alternate Text', 'wpcf'), '#description' => __('Alt text for the image, e.g. “The Mona Lisa”', 'wpcf'), '#name' => 'alt', '#value' => isset($last_settings['alt']) ? $last_settings['alt'] : $alt);
$form['alignment'] = array('#type' => 'radios', '#title' => __('Alignment', 'wpcf'), '#name' => 'alignment', '#default_value' => isset($last_settings['alignment']) ? $last_settings['alignment'] : 'none', '#options' => array(__('None', 'wpcf') => 'none', __('Left', 'wpcf') => 'left', __('Center', 'wpcf') => 'center', __('Right', 'wpcf') => 'right'));
if (!in_array($post_type, array('view', 'view-template'))) {
$attributes_outsider = $image_data['is_outsider'] ? array('disabled' => 'disabled') : array();
$attributes_attachment = !$image_data['is_attachment'] ? array('disabled' => 'disabled') : array();
} else {
$attributes_outsider = array();
$attributes_attachment = array();
}
if (!in_array($post_type, array('view', 'view-template')) && $image_data['is_outsider']) {
$form['notice'] = array('#type' => 'markup', '#markup' => '<div class="message error" style="margin:0 0 20px 0;"><p>' . __('Types can only resize images that you upload to this site and not images from other domains.', 'wpcf') . '</p></div>');
} else {
if ($image_data['is_outsider']) {
$form['notice'] = array('#type' => 'markup', '#markup' => '<div class="message error" style="margin:0 0 20px 0;"><p>' . __('Types will be able to resize images that are uploaded to the post. If you specify URLs of images on other sites, Types will not resize them.', 'wpcf') . '</p></div>');
}
}
//.........这里部分代码省略.........