Initial Commit
893
plugins/jetpack/modules/contact-form/admin.php
Normal file
|
@ -0,0 +1,893 @@
|
|||
<?php
|
||||
|
||||
function grunion_menu_alter() {
|
||||
if( is_rtl() ){
|
||||
wp_enqueue_style( 'grunion-menu-alter', plugins_url( 'css/rtl/menu-alter-rtl.css', __FILE__ ) );
|
||||
} else {
|
||||
wp_enqueue_style( 'grunion-menu-alter', plugins_url( 'css/menu-alter.css', __FILE__ ) );
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', 'grunion_menu_alter' );
|
||||
|
||||
/**
|
||||
* Add a contact form button to the post composition screen
|
||||
*/
|
||||
add_action( 'media_buttons', 'grunion_media_button', 999 );
|
||||
function grunion_media_button( ) {
|
||||
global $post_ID, $temp_ID, $pagenow;
|
||||
|
||||
if ( 'press-this.php' === $pagenow ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$iframe_post_id = (int) (0 == $post_ID ? $temp_ID : $post_ID);
|
||||
$title = __( 'Add Contact Form', 'jetpack' );
|
||||
$plugin_url = esc_url( GRUNION_PLUGIN_URL );
|
||||
$site_url = esc_url( admin_url( "/admin-ajax.php?post_id={$iframe_post_id}&action=grunion_form_builder&TB_iframe=true&width=768" ) );
|
||||
?>
|
||||
|
||||
<a id="insert-jetpack-contact-form" class="button thickbox" title="<?php echo esc_attr( $title ); ?>" data-editor="content" href="<?php echo $site_url ?>&id=add_form">
|
||||
<span class="jetpack-contact-form-icon"></span> <?php echo esc_html( $title ); ?>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_grunion_form_builder', 'grunion_display_form_view' );
|
||||
|
||||
function grunion_display_form_view() {
|
||||
require_once GRUNION_PLUGIN_DIR . 'grunion-form-view.php';
|
||||
exit;
|
||||
}
|
||||
|
||||
// feedback specific css items
|
||||
add_action( 'admin_print_styles', 'grunion_admin_css' );
|
||||
function grunion_admin_css() {
|
||||
global $current_screen;
|
||||
if ( is_null( $current_screen ) ) {
|
||||
return;
|
||||
}
|
||||
if ( ! in_array( $current_screen->id, array( 'edit-feedback', 'jetpack_page_omnisearch', 'dashboard_page_omnisearch' ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'wp-lists' );
|
||||
?>
|
||||
|
||||
<style type='text/css'>
|
||||
.add-new-h2, .view-switch, body.no-js .tablenav select[name^=action], body.no-js #doaction, body.no-js #doaction2 {
|
||||
display: none
|
||||
}
|
||||
|
||||
.column-feedback_from img {
|
||||
float:left;
|
||||
margin-right:10px;
|
||||
margin-top:3px;
|
||||
}
|
||||
|
||||
.widefat .column-feedback_from {
|
||||
width: 17%;
|
||||
}
|
||||
.widefat .column-feedback_date {
|
||||
width: 17%;
|
||||
}
|
||||
|
||||
.spam a {
|
||||
color: #BC0B0B;
|
||||
}
|
||||
|
||||
.untrash a {
|
||||
color: #D98500;
|
||||
}
|
||||
|
||||
.unspam a {
|
||||
color: #D98500;
|
||||
}
|
||||
|
||||
#icon-edit.icon32-posts-feedback, #icon-post.icon32-posts-feedback { background: url("<?php echo GRUNION_PLUGIN_URL; ?>images/grunion-menu-big.png") no-repeat !important; }
|
||||
@media only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
|
||||
#icon-edit.icon32-posts-feedback, #icon-post.icon32-posts-feedback { background: url("<?php echo GRUNION_PLUGIN_URL; ?>images/grunion-menu-big-2x.png") no-repeat !important; background-size: 30px 31px !important; }
|
||||
}
|
||||
|
||||
#icon-edit.icon32-posts-feedback { background-position: 2px 2px !important; }
|
||||
|
||||
</style>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Hack a 'Bulk Spam' option for bulk edit in other than spam view
|
||||
* Hack a 'Bulk Delete' option for bulk edit in spam view
|
||||
*
|
||||
* There isn't a better way to do this until
|
||||
* http://core.trac.wordpress.org/changeset/17297 is resolved
|
||||
*/
|
||||
add_action( 'admin_head', 'grunion_add_bulk_edit_option' );
|
||||
function grunion_add_bulk_edit_option() {
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( is_null( $screen ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'edit-feedback' != $screen->id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When viewing spam we want to be able to be able to bulk delete
|
||||
// When viewing anything we want to be able to bulk move to spam
|
||||
if ( isset( $_GET['post_status'] ) && 'spam' == $_GET['post_status'] ) {
|
||||
// Create Delete Permanently bulk item
|
||||
$option_val = 'delete';
|
||||
$option_txt = __( 'Delete Permanently', 'jetpack' );
|
||||
$pseudo_selector = 'last-child';
|
||||
|
||||
} else {
|
||||
// Create Mark Spam bulk item
|
||||
$option_val = 'spam';
|
||||
$option_txt = __( 'Mark as Spam', 'jetpack' );
|
||||
$pseudo_selector = 'first-child';
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#posts-filter .actions select').filter('[name=action], [name=action2]').find('option:<?php echo $pseudo_selector; ?>').after('<option value="<?php echo $option_val; ?>"><?php echo esc_attr( $option_txt ); ?></option>' );
|
||||
})
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Hack an 'Empty Spam' button to spam view
|
||||
*
|
||||
* Leverages core's delete_all functionality
|
||||
*/
|
||||
add_action( 'admin_head', 'grunion_add_empty_spam_button' );
|
||||
function grunion_add_empty_spam_button() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( is_null( $screen ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only add to feedback, only to spam view
|
||||
if ( 'edit-feedback' != $screen->id
|
||||
|| empty( $_GET['post_status'] )
|
||||
|| 'spam' !== $_GET['post_status'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get HTML for the button
|
||||
$button_html = wp_nonce_field( 'bulk-destroy', '_destroy_nonce', true, false );
|
||||
$button_html .= get_submit_button( __( 'Empty Spam', 'jetpack' ), 'apply', 'delete_all', false );
|
||||
|
||||
// Add the button next to the filter button via js
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#posts-filter #post-query-submit').after('<?php echo $button_html; ?>' );
|
||||
})
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a bulk spam report
|
||||
*/
|
||||
add_action( 'admin_init', 'grunion_handle_bulk_spam' );
|
||||
function grunion_handle_bulk_spam() {
|
||||
global $pagenow;
|
||||
|
||||
if ( 'edit.php' != $pagenow
|
||||
|| ( empty( $_REQUEST['post_type'] ) || 'feedback' != $_REQUEST['post_type'] ) )
|
||||
return;
|
||||
|
||||
// Slip in a success message
|
||||
if ( ! empty( $_REQUEST['message'] ) && 'marked-spam' == $_REQUEST['message'] )
|
||||
add_action( 'admin_notices', 'grunion_message_bulk_spam' );
|
||||
|
||||
if ( ( empty( $_REQUEST['action'] ) || 'spam' != $_REQUEST['action'] ) && ( empty( $_REQUEST['action2'] ) || 'spam' != $_REQUEST['action2'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
check_admin_referer('bulk-posts');
|
||||
|
||||
if ( empty( $_REQUEST['post'] ) ) {
|
||||
wp_safe_redirect( wp_get_referer() );
|
||||
exit;
|
||||
}
|
||||
|
||||
$post_ids = array_map( 'intval', $_REQUEST['post'] );
|
||||
|
||||
foreach( $post_ids as $post_id ) {
|
||||
if ( ! current_user_can( "edit_page", $post_id ) ) {
|
||||
wp_die( __( 'You are not allowed to manage this item.', 'jetpack' ) );
|
||||
}
|
||||
|
||||
$post = array(
|
||||
'ID' => $post_id,
|
||||
'post_status' => 'spam',
|
||||
);
|
||||
$akismet_values = get_post_meta( $post_id, '_feedback_akismet_values', true );
|
||||
wp_update_post( $post );
|
||||
|
||||
/**
|
||||
* Fires after a comment has been marked by Akismet.
|
||||
*
|
||||
* Typically this means the comment is spam.
|
||||
*
|
||||
* @module contact-form
|
||||
*
|
||||
* @since 2.2.0
|
||||
*
|
||||
* @param string $comment_status Usually is 'spam', otherwise 'ham'.
|
||||
* @param array $akismet_values From '_feedback_akismet_values' in comment meta
|
||||
*/
|
||||
do_action( 'contact_form_akismet', 'spam', $akismet_values );
|
||||
}
|
||||
|
||||
$redirect_url = add_query_arg( 'message', 'marked-spam', wp_get_referer() );
|
||||
wp_safe_redirect( $redirect_url );
|
||||
exit;
|
||||
}
|
||||
|
||||
function grunion_message_bulk_spam() {
|
||||
echo '<div class="updated"><p>' . __( 'Feedback(s) marked as spam', 'jetpack' ) . '</p></div>';
|
||||
}
|
||||
|
||||
// remove admin UI parts that we don't support in feedback management
|
||||
add_action( 'admin_menu', 'grunion_admin_menu' );
|
||||
function grunion_admin_menu() {
|
||||
global $menu, $submenu;
|
||||
unset( $submenu['edit.php?post_type=feedback'] );
|
||||
}
|
||||
|
||||
add_filter( 'bulk_actions-edit-feedback', 'grunion_admin_bulk_actions' );
|
||||
function grunion_admin_bulk_actions( $actions ) {
|
||||
global $current_screen;
|
||||
if ( 'edit-feedback' != $current_screen->id )
|
||||
return $actions;
|
||||
|
||||
unset( $actions['edit'] );
|
||||
return $actions;
|
||||
}
|
||||
|
||||
add_filter( 'views_edit-feedback', 'grunion_admin_view_tabs' );
|
||||
function grunion_admin_view_tabs( $views ) {
|
||||
global $current_screen;
|
||||
if ( 'edit-feedback' != $current_screen->id )
|
||||
return $actions;
|
||||
|
||||
unset( $views['publish'] );
|
||||
|
||||
preg_match( '|post_type=feedback\'( class="current")?\>(.*)\<span class=|', $views['all'], $match );
|
||||
if ( !empty( $match[2] ) )
|
||||
$views['all'] = str_replace( $match[2], __( 'Messages', 'jetpack' ) . ' ', $views['all'] );
|
||||
|
||||
return $views;
|
||||
}
|
||||
|
||||
add_filter( 'manage_feedback_posts_columns', 'grunion_post_type_columns_filter' );
|
||||
function grunion_post_type_columns_filter( $cols ) {
|
||||
$cols = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'feedback_from' => __( 'From', 'jetpack' ),
|
||||
'feedback_message' => __( 'Message', 'jetpack' ),
|
||||
'feedback_date' => __( 'Date', 'jetpack' )
|
||||
);
|
||||
|
||||
return $cols;
|
||||
}
|
||||
|
||||
add_action( 'manage_posts_custom_column', 'grunion_manage_post_columns', 10, 2 );
|
||||
function grunion_manage_post_columns( $col, $post_id ) {
|
||||
global $post;
|
||||
|
||||
/**
|
||||
* Only call parse_fields_from_content if we're dealing with a Grunion custom column.
|
||||
*/
|
||||
if ( ! in_array( $col, array( 'feedback_date', 'feedback_from', 'feedback_message' ) ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content_fields = Grunion_Contact_Form_Plugin::parse_fields_from_content( $post_id );
|
||||
|
||||
switch ( $col ) {
|
||||
case 'feedback_from':
|
||||
$author_name = isset( $content_fields['_feedback_author'] ) ? $content_fields['_feedback_author'] : '';
|
||||
$author_email = isset( $content_fields['_feedback_author_email'] ) ? $content_fields['_feedback_author_email'] : '';
|
||||
$author_url = isset( $content_fields['_feedback_author_url'] ) ? $content_fields['_feedback_author_url'] : '';
|
||||
$author_ip = isset( $content_fields['_feedback_ip'] ) ? $content_fields['_feedback_ip'] : '';
|
||||
$form_url = isset( $post->post_parent ) ? get_permalink( $post->post_parent ) : null;
|
||||
|
||||
$author_name_line = '';
|
||||
if ( !empty( $author_name ) ) {
|
||||
if ( !empty( $author_email ) )
|
||||
$author_name_line = get_avatar( $author_email, 32 );
|
||||
|
||||
$author_name_line .= sprintf( "<strong>%s</strong><br />", esc_html( $author_name ) );
|
||||
}
|
||||
|
||||
$author_email_line = '';
|
||||
if ( !empty( $author_email ) ) {
|
||||
$author_email_line = sprintf( "<a href='%1\$s' target='_blank'>%2\$s</a><br />", esc_url( "mailto:" . $author_email ) , esc_html( $author_email ) );
|
||||
}
|
||||
|
||||
$author_url_line = '';
|
||||
if ( !empty( $author_url ) ) {
|
||||
$author_url_line = sprintf( "<a href='%1\$s'>%1\$s</a><br />", esc_url( $author_url ) );
|
||||
}
|
||||
|
||||
echo $author_name_line;
|
||||
echo $author_email_line;
|
||||
echo $author_url_line;
|
||||
echo "<a href='edit.php?post_type=feedback&s=" . urlencode( $author_ip );
|
||||
echo "&mode=detail'>" . esc_html( $author_ip ) . "</a><br />";
|
||||
if ( $form_url ) {
|
||||
echo '<a href="' . esc_url( $form_url ) . '">' . esc_html( $form_url ) . '</a>';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'feedback_message':
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
if ( isset( $content_fields['_feedback_subject'] ) ) {
|
||||
echo '<strong>';
|
||||
echo esc_html( $content_fields['_feedback_subject'] );
|
||||
echo '</strong>';
|
||||
echo '<br />';
|
||||
}
|
||||
echo sanitize_text_field( get_the_content( '' ) );
|
||||
echo '<br />';
|
||||
|
||||
$extra_fields = get_post_meta( $post_id, '_feedback_extra_fields', TRUE );
|
||||
if ( !empty( $extra_fields ) ) {
|
||||
echo '<br /><hr />';
|
||||
echo '<table cellspacing="0" cellpadding="0" style="">' . "\n";
|
||||
foreach ( (array) $extra_fields as $k => $v ) {
|
||||
// Remove prefix from exta fields
|
||||
echo "<tr><td align='right'><b>". esc_html( preg_replace( '#^\d+_#', '', $k ) ) ."</b></td><td>". sanitize_text_field( $v ) ."</td></tr>\n";
|
||||
}
|
||||
echo '</table>';
|
||||
}
|
||||
|
||||
echo '<div class="row-actions">';
|
||||
if ( $post->post_status == 'trash' ) {
|
||||
echo '<span class="untrash" id="feedback-restore-' . $post_id;
|
||||
echo '"><a title="';
|
||||
echo esc_attr__( 'Restore this item from the Trash', 'jetpack' );
|
||||
echo '" href="' . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-' . $post->post_type . '_' . $post->ID );
|
||||
echo '">' . __( 'Restore', 'jetpack' ) . '</a></span> | ';
|
||||
|
||||
echo "<span class='delete'> <a class='submitdelete' title='";
|
||||
echo esc_attr( __( 'Delete this item permanently', 'jetpack' ) );
|
||||
echo "' href='" . get_delete_post_link( $post->ID, '', true );
|
||||
echo "'>" . __( 'Delete Permanently', 'jetpack' ) . "</a></span>";
|
||||
?>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
$('#feedback-restore-<?php echo $post_id; ?>').click(function(e) {
|
||||
e.preventDefault();
|
||||
$.post(ajaxurl, {
|
||||
action: 'grunion_ajax_spam',
|
||||
post_id: '<?php echo $post_id; ?>',
|
||||
make_it: 'publish',
|
||||
sub_menu: jQuery('.subsubsub .current').attr('href'),
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>'
|
||||
},
|
||||
function(r) {
|
||||
$('#post-<?php echo $post_id; ?>')
|
||||
.css({backgroundColor: '#59C859'})
|
||||
.fadeOut(350, function() {
|
||||
$(this).remove();
|
||||
$('.subsubsub').html(r);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
} elseif ( $post->post_status == 'publish' ) {
|
||||
echo '<span class="spam" id="feedback-spam-' . $post_id;
|
||||
echo '"><a title="';
|
||||
echo __( 'Mark this message as spam', 'jetpack' );
|
||||
echo '" href="' . wp_nonce_url( admin_url( 'admin-ajax.php?post_id=' . $post_id . '&action=spam' ), 'spam-feedback_' . $post_id );
|
||||
echo '">Spam</a></span>';
|
||||
echo ' | ';
|
||||
|
||||
echo '<span class="delete" id="feedback-trash-' . $post_id;
|
||||
echo '">';
|
||||
echo '<a class="submitdelete" title="' . esc_attr__( 'Trash', 'jetpack' );
|
||||
echo '" href="' . get_delete_post_link( $post_id );
|
||||
echo '">' . __( 'Trash', 'jetpack' ) . '</a></span>';
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready( function($) {
|
||||
$('#feedback-spam-<?php echo $post_id; ?>').click( function(e) {
|
||||
e.preventDefault();
|
||||
$.post( ajaxurl, {
|
||||
action: 'grunion_ajax_spam',
|
||||
post_id: '<?php echo $post_id; ?>',
|
||||
make_it: 'spam',
|
||||
sub_menu: jQuery('.subsubsub .current').attr('href'),
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>'
|
||||
},
|
||||
function( r ) {
|
||||
$('#post-<?php echo $post_id; ?>')
|
||||
.css( {backgroundColor:'#FF7979'} )
|
||||
.fadeOut(350, function() {
|
||||
$(this).remove();
|
||||
$('.subsubsub').html(r);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('#feedback-trash-<?php echo $post_id; ?>').click(function(e) {
|
||||
e.preventDefault();
|
||||
$.post(ajaxurl, {
|
||||
action: 'grunion_ajax_spam',
|
||||
post_id: '<?php echo $post_id; ?>',
|
||||
make_it: 'trash',
|
||||
sub_menu: jQuery('.subsubsub .current').attr('href'),
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>'
|
||||
},
|
||||
function(r) {
|
||||
$('#post-<?php echo $post_id; ?>')
|
||||
.css({backgroundColor: '#FF7979'})
|
||||
.fadeOut(350, function() {
|
||||
$(this).remove();
|
||||
$('.subsubsub').html(r);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
} elseif ( $post->post_status == 'spam' ) {
|
||||
echo '<span class="unspam unapprove" id="feedback-ham-' . $post_id;
|
||||
echo '"><a title="';
|
||||
echo __( 'Mark this message as NOT spam', 'jetpack' );
|
||||
echo '" href="">Not Spam</a></span>';
|
||||
echo ' | ';
|
||||
|
||||
echo "<span class='delete' id='feedback-trash-" . $post_id;
|
||||
echo "'> <a class='submitdelete' title='";
|
||||
echo esc_attr( __( 'Delete this item permanently', 'jetpack' ) );
|
||||
echo "' href='" . get_delete_post_link( $post->ID, '', true );
|
||||
echo "'>" . __( 'Delete Permanently', 'jetpack' ) . "</a></span>";
|
||||
?>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready( function($) {
|
||||
$('#feedback-ham-<?php echo $post_id; ?>').click( function(e) {
|
||||
e.preventDefault();
|
||||
$.post( ajaxurl, {
|
||||
action: 'grunion_ajax_spam',
|
||||
post_id: '<?php echo $post_id; ?>',
|
||||
make_it: 'ham',
|
||||
sub_menu: jQuery('.subsubsub .current').attr('href'),
|
||||
_ajax_nonce: '<?php echo wp_create_nonce( 'grunion-post-status-' . $post_id ); ?>'
|
||||
},
|
||||
function( r ) {
|
||||
$('#post-<?php echo $post_id; ?>')
|
||||
.css( {backgroundColor:'#59C859'} )
|
||||
.fadeOut(350, function() {
|
||||
$(this).remove();
|
||||
$('.subsubsub').html(r);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
break;
|
||||
|
||||
case 'feedback_date':
|
||||
|
||||
$date_time_format = _x( '%1$s \a\t %2$s', '{$date_format} \a\t {$time_format}', 'jetpack' );
|
||||
$date_time_format = sprintf( $date_time_format, get_option( 'date_format' ), get_option( 'time_format' ) );
|
||||
$time = date_i18n( $date_time_format, get_the_time( 'U' ) );
|
||||
|
||||
echo $time;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function grunion_esc_attr( $attr ) {
|
||||
$out = esc_attr( $attr );
|
||||
// we also have to entity-encode square brackets so they don't interfere with the shortcode parser
|
||||
// FIXME: do this better - just stripping out square brackets for now since they mysteriously keep reappearing
|
||||
$out = str_replace( '[', '', $out );
|
||||
$out = str_replace( ']', '', $out );
|
||||
return $out;
|
||||
}
|
||||
|
||||
function grunion_sort_objects( $a, $b ) {
|
||||
if ( isset($a['order']) && isset($b['order']) )
|
||||
return $a['order'] - $b['order'];
|
||||
return 0;
|
||||
}
|
||||
|
||||
// take an array of field types from the form builder, and construct a shortcode form
|
||||
// returns both the shortcode form, and HTML markup representing a preview of the form
|
||||
function grunion_ajax_shortcode() {
|
||||
check_ajax_referer( 'grunion_shortcode' );
|
||||
|
||||
$attributes = array();
|
||||
|
||||
foreach ( array( 'subject', 'to' ) as $attribute ) {
|
||||
if ( isset( $_POST[$attribute] ) && strlen( $_POST[$attribute] ) ) {
|
||||
$attributes[$attribute] = stripslashes( $_POST[$attribute] );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_array( $_POST['fields'] ) ) {
|
||||
$fields = stripslashes_deep( $_POST['fields'] );
|
||||
usort( $fields, 'grunion_sort_objects' );
|
||||
|
||||
$field_shortcodes = array();
|
||||
|
||||
foreach ( $fields as $field ) {
|
||||
$field_attributes = array();
|
||||
|
||||
if ( isset( $field['required'] ) && 'true' === $field['required'] ) {
|
||||
$field_attributes['required'] = 'true';
|
||||
}
|
||||
|
||||
foreach ( array( 'options', 'label', 'type' ) as $attribute ) {
|
||||
if ( isset( $field[$attribute] ) ) {
|
||||
$field_attributes[$attribute] = $field[$attribute];
|
||||
}
|
||||
}
|
||||
|
||||
$field_shortcodes[] = new Grunion_Contact_Form_Field( $field_attributes );
|
||||
}
|
||||
}
|
||||
|
||||
$grunion = new Grunion_Contact_Form( $attributes, $field_shortcodes );
|
||||
|
||||
die( "\n$grunion\n" );
|
||||
}
|
||||
|
||||
// takes a post_id, extracts the contact-form shortcode from that post (if there is one), parses it,
|
||||
// and constructs a json object representing its contents and attributes
|
||||
function grunion_ajax_shortcode_to_json() {
|
||||
global $post, $grunion_form;
|
||||
|
||||
check_ajax_referer( 'grunion_shortcode_to_json' );
|
||||
|
||||
if ( !isset( $_POST['content'] ) || !is_numeric( $_POST['post_id'] ) ) {
|
||||
die( '-1' );
|
||||
}
|
||||
|
||||
$content = stripslashes( $_POST['content'] );
|
||||
|
||||
// doesn't look like a post with a [contact-form] already.
|
||||
if ( false === has_shortcode( $content, 'contact-form' ) ) {
|
||||
die( '' );
|
||||
}
|
||||
|
||||
$post = get_post( $_POST['post_id'] );
|
||||
|
||||
do_shortcode( $content );
|
||||
|
||||
$grunion = Grunion_Contact_Form::$last;
|
||||
|
||||
$out = array(
|
||||
'to' => '',
|
||||
'subject' => '',
|
||||
'fields' => array(),
|
||||
);
|
||||
|
||||
foreach ( $grunion->fields as $field ) {
|
||||
$out['fields'][$field->get_attribute( 'id' )] = $field->attributes;
|
||||
}
|
||||
|
||||
$to = $grunion->get_attribute( 'to' );
|
||||
$subject = $grunion->get_attribute( 'subject' );
|
||||
foreach ( array( 'to', 'subject' ) as $attribute ) {
|
||||
$value = $grunion->get_attribute( $attribute );
|
||||
if ( isset( $grunion->defaults[$attribute] ) && $value == $grunion->defaults[$attribute] ) {
|
||||
$value = '';
|
||||
}
|
||||
$out[$attribute] = $value;
|
||||
}
|
||||
|
||||
die( json_encode( $out ) );
|
||||
}
|
||||
|
||||
|
||||
add_action( 'wp_ajax_grunion_shortcode', 'grunion_ajax_shortcode' );
|
||||
add_action( 'wp_ajax_grunion_shortcode_to_json', 'grunion_ajax_shortcode_to_json' );
|
||||
|
||||
|
||||
// process row-action spam/not spam clicks
|
||||
add_action( 'wp_ajax_grunion_ajax_spam', 'grunion_ajax_spam' );
|
||||
function grunion_ajax_spam() {
|
||||
global $wpdb;
|
||||
|
||||
if ( empty( $_POST['make_it'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$post_id = (int) $_POST['post_id'];
|
||||
check_ajax_referer( 'grunion-post-status-' . $post_id );
|
||||
if ( ! current_user_can( "edit_page", $post_id ) ) {
|
||||
wp_die( __( 'You are not allowed to manage this item.', 'jetpack' ) );
|
||||
}
|
||||
|
||||
require_once dirname( __FILE__ ) . '/grunion-contact-form.php';
|
||||
|
||||
$current_menu = '';
|
||||
if ( isset( $_POST['sub_menu'] ) && preg_match( '|post_type=feedback|', $_POST['sub_menu'] ) ) {
|
||||
if ( preg_match( '|post_status=spam|', $_POST['sub_menu'] ) ) {
|
||||
$current_menu = 'spam';
|
||||
}
|
||||
elseif ( preg_match( '|post_status=trash|', $_POST['sub_menu'] ) ) {
|
||||
$current_menu = 'trash';
|
||||
}
|
||||
else {
|
||||
$current_menu = 'messages';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$post = get_post( $post_id );
|
||||
$post_type_object = get_post_type_object( $post->post_type );
|
||||
$akismet_values = get_post_meta( $post_id, '_feedback_akismet_values', TRUE );
|
||||
if ( $_POST['make_it'] == 'spam' ) {
|
||||
$post->post_status = 'spam';
|
||||
$status = wp_insert_post( $post );
|
||||
wp_transition_post_status( 'spam', 'publish', $post );
|
||||
|
||||
/** This action is already documented in modules/contact-form/admin.php */
|
||||
do_action( 'contact_form_akismet', 'spam', $akismet_values );
|
||||
} elseif ( $_POST['make_it'] == 'ham' ) {
|
||||
$post->post_status = 'publish';
|
||||
$status = wp_insert_post( $post );
|
||||
wp_transition_post_status( 'publish', 'spam', $post );
|
||||
|
||||
/** This action is already documented in modules/contact-form/admin.php */
|
||||
do_action( 'contact_form_akismet', 'ham', $akismet_values );
|
||||
|
||||
$comment_author_email = $reply_to_addr = $message = $to = $headers = false;
|
||||
$blog_url = parse_url( site_url() );
|
||||
|
||||
// resend the original email
|
||||
$email = get_post_meta( $post_id, '_feedback_email', TRUE );
|
||||
$content_fields = Grunion_Contact_Form_Plugin::parse_fields_from_content( $post_id );
|
||||
|
||||
if ( ! empty( $email ) && !empty( $content_fields ) ) {
|
||||
if ( isset( $content_fields['_feedback_author_email'] ) ) {
|
||||
$comment_author_email = $content_fields['_feedback_author_email'];
|
||||
}
|
||||
|
||||
if ( isset( $email['to'] ) ) {
|
||||
$to = $email['to'];
|
||||
}
|
||||
|
||||
if ( isset( $email['message'] ) ) {
|
||||
$message = $email['message'];
|
||||
}
|
||||
|
||||
if ( isset( $email['headers'] ) ) {
|
||||
$headers = $email['headers'];
|
||||
}
|
||||
else {
|
||||
$headers = 'From: "' . $content_fields['_feedback_author'] .'" <wordpress@' . $blog_url['host'] . ">\r\n";
|
||||
|
||||
if ( ! empty( $comment_author_email ) ){
|
||||
$reply_to_addr = $comment_author_email;
|
||||
}
|
||||
elseif ( is_array( $to ) ) {
|
||||
$reply_to_addr = $to[0];
|
||||
}
|
||||
|
||||
if ( $reply_to_addr ) {
|
||||
$headers .= 'Reply-To: "' . $content_fields['_feedback_author'] .'" <' . $reply_to_addr . ">\r\n";
|
||||
}
|
||||
|
||||
$headers .= "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"";
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the subject of the email sent after a contact form submission.
|
||||
*
|
||||
* @module contact-form
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $content_fields['_feedback_subject'] Feedback's subject line.
|
||||
* @param array $content_fields['_feedback_all_fields'] Feedback's data from old fields.
|
||||
*/
|
||||
$subject = apply_filters( 'contact_form_subject', $content_fields['_feedback_subject'], $content_fields['_feedback_all_fields'] );
|
||||
|
||||
wp_mail( $to, $subject, $message, $headers );
|
||||
}
|
||||
} elseif( $_POST['make_it'] == 'publish' ) {
|
||||
if ( ! current_user_can($post_type_object->cap->delete_post, $post_id) ) {
|
||||
wp_die( __( 'You are not allowed to move this item out of the Trash.', 'jetpack' ) );
|
||||
}
|
||||
|
||||
if ( ! wp_untrash_post($post_id) ) {
|
||||
wp_die( __( 'Error in restoring from Trash.', 'jetpack' ) );
|
||||
}
|
||||
|
||||
} elseif( $_POST['make_it'] == 'trash' ) {
|
||||
if ( ! current_user_can($post_type_object->cap->delete_post, $post_id) ) {
|
||||
wp_die( __( 'You are not allowed to move this item to the Trash.', 'jetpack' ) );
|
||||
}
|
||||
|
||||
if ( ! wp_trash_post($post_id) ) {
|
||||
wp_die( __( 'Error in moving to Trash.', 'jetpack' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "
|
||||
SELECT post_status,
|
||||
COUNT( * ) AS post_count
|
||||
FROM `{$wpdb->posts}`
|
||||
WHERE post_type = 'feedback'
|
||||
GROUP BY post_status
|
||||
";
|
||||
$status_count = (array) $wpdb->get_results( $sql, ARRAY_A );
|
||||
|
||||
$status = array();
|
||||
$status_html = '';
|
||||
foreach ( $status_count as $i => $row ) {
|
||||
$status[$row['post_status']] = $row['post_count'];
|
||||
}
|
||||
|
||||
if ( isset( $status['publish'] ) ) {
|
||||
$status_html .= '<li><a href="edit.php?post_type=feedback"';
|
||||
if ( $current_menu == 'messages' ) {
|
||||
$status_html .= ' class="current"';
|
||||
}
|
||||
|
||||
$status_html .= '>' . __( 'Messages', 'jetpack' ) . ' <span class="count">';
|
||||
$status_html .= '(' . number_format( $status['publish'] ) . ')';
|
||||
$status_html .= '</span></a> |</li>';
|
||||
}
|
||||
|
||||
if ( isset( $status['trash'] ) ) {
|
||||
$status_html .= '<li><a href="edit.php?post_status=trash&post_type=feedback"';
|
||||
if ( $current_menu == 'trash' )
|
||||
$status_html .= ' class="current"';
|
||||
|
||||
$status_html .= '>' . __( 'Trash', 'jetpack' ) . ' <span class="count">';
|
||||
$status_html .= '(' . number_format( $status['trash'] ) . ')';
|
||||
$status_html .= '</span></a>';
|
||||
if ( isset( $status['spam'] ) )
|
||||
$status_html .= ' |';
|
||||
$status_html .= '</li>';
|
||||
}
|
||||
|
||||
if ( isset( $status['spam'] ) ) {
|
||||
$status_html .= '<li><a href="edit.php?post_status=spam&post_type=feedback"';
|
||||
if ( $current_menu == 'spam' )
|
||||
$status_html .= ' class="current"';
|
||||
|
||||
$status_html .= '>' . __( 'Spam', 'jetpack' ) . ' <span class="count">';
|
||||
$status_html .= '(' . number_format( $status['spam'] ) . ')';
|
||||
$status_html .= '</span></a></li>';
|
||||
}
|
||||
|
||||
echo $status_html;
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action( 'omnisearch_add_providers', 'grunion_omnisearch_add_providers' );
|
||||
function grunion_omnisearch_add_providers() {
|
||||
// Feedback uses capability_type 'page'
|
||||
if ( current_user_can( 'edit_pages' ) ) {
|
||||
require_once( GRUNION_PLUGIN_DIR . '/grunion-omnisearch.php' );
|
||||
new Jetpack_Omnisearch_Grunion;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the scripts that will add the "Check for Spam" button to the Feedbacks dashboard page.
|
||||
*/
|
||||
function grunion_enable_spam_recheck() {
|
||||
if ( ! defined( 'AKISMET_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
// Only add to feedback, only to non-spam view
|
||||
if ( 'edit-feedback' != $screen->id || ( ! empty( $_GET['post_status'] ) && 'spam' == $_GET['post_status'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add the scripts that handle the spam check event.
|
||||
wp_register_script( 'grunion-admin', plugin_dir_url( __FILE__ ) . 'js/grunion-admin.js', array( 'jquery' ) );
|
||||
wp_enqueue_script( 'grunion-admin' );
|
||||
|
||||
wp_enqueue_style( 'grunion.css' );
|
||||
|
||||
// Add the actual "Check for Spam" button.
|
||||
add_action( 'admin_head', 'grunion_check_for_spam_button' );
|
||||
}
|
||||
|
||||
add_action( 'admin_enqueue_scripts', 'grunion_enable_spam_recheck' );
|
||||
|
||||
/**
|
||||
* Add the "Check for Spam" button to the Feedbacks dashboard page.
|
||||
*/
|
||||
function grunion_check_for_spam_button() {
|
||||
// Get HTML for the button
|
||||
$button_html = get_submit_button(
|
||||
__( 'Check for Spam', 'jetpack' ),
|
||||
'secondary',
|
||||
'jetpack-check-feedback-spam',
|
||||
false,
|
||||
array( 'class' => 'jetpack-check-feedback-spam' )
|
||||
);
|
||||
$button_html .= '<span class="jetpack-check-feedback-spam-spinner"></span>';
|
||||
|
||||
// Add the button next to the filter button via js
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery( function( $ ) {
|
||||
$( '#posts-filter #post-query-submit' ).after( '<?php echo $button_html; ?>' );
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Recheck all approved feedbacks for spam.
|
||||
*/
|
||||
function grunion_recheck_queue() {
|
||||
global $wpdb;
|
||||
|
||||
$query = 'post_type=feedback&post_status=publish';
|
||||
|
||||
if ( isset( $_POST['limit'], $_POST['offset'] ) ) {
|
||||
$query .= '&posts_per_page=' . intval( $_POST['limit'] ) . '&offset=' . intval( $_POST['offset'] );
|
||||
}
|
||||
|
||||
$approved_feedbacks = get_posts( $query );
|
||||
|
||||
foreach ( $approved_feedbacks as $feedback ) {
|
||||
$meta = get_post_meta( $feedback->ID, '_feedback_akismet_values', true );
|
||||
|
||||
/**
|
||||
* Filter whether the submitted feedback is considered as spam.
|
||||
*
|
||||
* @module contact-form
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param bool false Is the submitted feedback spam? Default to false.
|
||||
* @param array $meta Feedack values returned by the Akismet plugin.
|
||||
*/
|
||||
$is_spam = apply_filters( 'jetpack_contact_form_is_spam', false, $meta );
|
||||
|
||||
if ( $is_spam ) {
|
||||
wp_update_post( array( 'ID' => $feedback->ID, 'post_status' => 'spam' ) );
|
||||
/** This action is already documented in modules/contact-form/admin.php */
|
||||
do_action( 'contact_form_akismet', 'spam', $akismet_values );
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json( array(
|
||||
'processed' => count( $approved_feedbacks ),
|
||||
) );
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_grunion_recheck_queue', 'grunion_recheck_queue' );
|
14
plugins/jetpack/modules/contact-form/css/grunion.css
Normal file
|
@ -0,0 +1,14 @@
|
|||
.contact-form .clear-form { clear: both; }
|
||||
.contact-form input[type='text'], .contact-form input[type='email'] { width: 300px; max-width: 98%; margin-bottom: 13px; }
|
||||
.contact-form select { margin-bottom: 13px; }
|
||||
.contact-form textarea { height: 200px; width: 80%; float: none; margin-bottom: 13px; }
|
||||
.contact-form input[type='radio'], .contact-form input[type='checkbox'] { float: none; margin-bottom: 13px; }
|
||||
.contact-form label { margin-bottom: 3px; float: none; font-weight: bold; display: block; }
|
||||
.contact-form label.checkbox, .contact-form label.radio { margin-bottom: 3px; float: none; font-weight: bold; display: inline-block; }
|
||||
.contact-form label span { color: #AAA; margin-left: 4px; font-weight: normal; }
|
||||
.contact-form-submission { margin-bottom: 4em; padding: 1.5em 1em; }
|
||||
.contact-form-submission p { margin: 0 auto; }
|
||||
.form-errors .form-error-message { color: red; }
|
||||
.textwidget .contact-form input[type='text'], .textwidget .contact-form input[type='email'], .textwidget .contact-form textarea { width: 250px; max-width: 100%; box-sizing: border-box; }
|
||||
#jetpack-check-feedback-spam { margin: 1px 8px 0px 0px; }
|
||||
.jetpack-check-feedback-spam-spinner { display: inline-block; margin-top: 7px; }
|
73
plugins/jetpack/modules/contact-form/css/menu-alter-rtl.css
Normal file
|
@ -0,0 +1,73 @@
|
|||
#menu-posts-feedback .wp-menu-image img {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
#adminmenu .menu-icon-feedback div.wp-menu-image:before {
|
||||
content: '\f175';
|
||||
margin-right: -1px;
|
||||
}
|
||||
|
||||
.jetpack-contact-form-icon:before {
|
||||
content: '\f175';
|
||||
color: #888;
|
||||
vertical-align: text-bottom;
|
||||
font: normal 18px/1 'dashicons';
|
||||
speak: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image {
|
||||
background: url(../images/grunion-menu-hover.png) no-repeat 7px 7px !important;
|
||||
background-size: 15px 16px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background: url(../images/grunion-menu.png) no-repeat 7px 7px !important;
|
||||
background-size: 15px 16px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon {
|
||||
background: url(../images/grunion-form.png) no-repeat;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-size: 13px 12px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media only screen and (min--moz-device-pixel-ratio: 1.5),
|
||||
only screen and (-o-min-device-pixel-ratio: 3/2),
|
||||
only screen and (-webkit-min-device-pixel-ratio: 1.5),
|
||||
only screen and (min-device-pixel-ratio: 1.5) {
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image {
|
||||
background-image: url(../images/grunion-menu-hover-2x.png);
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background-image: url(../images/grunion-menu-2x.png);
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon {
|
||||
background-image: url(../images/grunion-form-2x.png);
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
}
|
1
plugins/jetpack/modules/contact-form/css/menu-alter-rtl.min.css
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
#menu-posts-feedback .wp-menu-image img{display:none}#adminmenu .menu-icon-feedback div.wp-menu-image{background:none!important}#adminmenu .menu-icon-feedback div.wp-menu-image:before{content:'\f175';margin-right:-1px}.jetpack-contact-form-icon:before{content:'\f175';color:#888;vertical-align:text-bottom;font:400 18px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image{background:url(../images/grunion-menu-hover.png) 7px 7px/15px 16px no-repeat!important}.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image{background:url(../images/grunion-menu.png) 7px 7px/15px 16px no-repeat!important}.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image:before{display:none}.pre-mp6 .jetpack-contact-form-icon{background:url(../images/grunion-form.png) no-repeat;width:16px;height:16px;display:inline-block;vertical-align:middle;background-size:13px 12px!important}.pre-mp6 .jetpack-contact-form-icon:before{display:none}@media only screen and (min--moz-device-pixel-ratio:1.5),only screen and (-o-min-device-pixel-ratio:3/2),only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-device-pixel-ratio:1.5){.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image{background-image:url(../images/grunion-menu-hover-2x.png)}.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image{background-image:url(../images/grunion-menu-2x.png)}.pre-mp6 .jetpack-contact-form-icon{background-image:url(../images/grunion-form-2x.png);vertical-align:bottom}}
|
73
plugins/jetpack/modules/contact-form/css/menu-alter.css
Normal file
|
@ -0,0 +1,73 @@
|
|||
#menu-posts-feedback .wp-menu-image img {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
#adminmenu .menu-icon-feedback div.wp-menu-image:before {
|
||||
content: '\f175';
|
||||
margin-left: -1px;
|
||||
}
|
||||
|
||||
.jetpack-contact-form-icon:before {
|
||||
content: '\f175';
|
||||
color: #888;
|
||||
vertical-align: text-bottom;
|
||||
font: normal 18px/1 'dashicons';
|
||||
speak: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image {
|
||||
background: url(../images/grunion-menu-hover.png) no-repeat 7px 7px !important;
|
||||
background-size: 15px 16px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background: url(../images/grunion-menu.png) no-repeat 7px 7px !important;
|
||||
background-size: 15px 16px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon {
|
||||
background: url(../images/grunion-form.png) no-repeat;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-size: 13px 12px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media only screen and (min--moz-device-pixel-ratio: 1.5),
|
||||
only screen and (-o-min-device-pixel-ratio: 3/2),
|
||||
only screen and (-webkit-min-device-pixel-ratio: 1.5),
|
||||
only screen and (min-device-pixel-ratio: 1.5) {
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image {
|
||||
background-image: url(../images/grunion-menu-hover-2x.png);
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background-image: url(../images/grunion-menu-2x.png);
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon {
|
||||
background-image: url(../images/grunion-form-2x.png);
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
}
|
1
plugins/jetpack/modules/contact-form/css/menu-alter.min.css
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
#menu-posts-feedback .wp-menu-image img{display:none}#adminmenu .menu-icon-feedback div.wp-menu-image{background:none!important}#adminmenu .menu-icon-feedback div.wp-menu-image:before{content:'\f175';margin-left:-1px}.jetpack-contact-form-icon:before{content:'\f175';color:#888;vertical-align:text-bottom;font:400 18px/1 dashicons;speak:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image{background:url(../images/grunion-menu-hover.png) 7px 7px/15px 16px no-repeat!important}.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image{background:url(../images/grunion-menu.png) 7px 7px/15px 16px no-repeat!important}.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image:before{display:none}.pre-mp6 .jetpack-contact-form-icon{background:url(../images/grunion-form.png) no-repeat;width:16px;height:16px;display:inline-block;vertical-align:middle;background-size:13px 12px!important}.pre-mp6 .jetpack-contact-form-icon:before{display:none}@media only screen and (min--moz-device-pixel-ratio:1.5),only screen and (-o-min-device-pixel-ratio:3/2),only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-device-pixel-ratio:1.5){.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image{background-image:url(../images/grunion-menu-hover-2x.png)}.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image{background-image:url(../images/grunion-menu-2x.png)}.pre-mp6 .jetpack-contact-form-icon{background-image:url(../images/grunion-form-2x.png);vertical-align:bottom}}
|
16
plugins/jetpack/modules/contact-form/css/rtl/grunion-rtl.css
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* This file was automatically generated on Oct 02 2015 21:49:32 */
|
||||
|
||||
.contact-form .clear-form { clear: both; }
|
||||
.contact-form input[type='text'], .contact-form input[type='email'] { width: 300px; max-width: 98%; margin-bottom: 13px; }
|
||||
.contact-form select { margin-bottom: 13px; }
|
||||
.contact-form textarea { height: 200px; width: 80%; float: none; margin-bottom: 13px; }
|
||||
.contact-form input[type='radio'], .contact-form input[type='checkbox'] { float: none; margin-bottom: 13px; }
|
||||
.contact-form label { margin-bottom: 3px; float: none; font-weight: bold; display: block; }
|
||||
.contact-form label.checkbox, .contact-form label.radio { margin-bottom: 3px; float: none; font-weight: bold; display: inline-block; }
|
||||
.contact-form label span { color: #AAA; margin-right: 4px; font-weight: normal; }
|
||||
.contact-form-submission { margin-bottom: 4em; padding: 1.5em 1em; }
|
||||
.contact-form-submission p { margin: 0 auto; }
|
||||
.form-errors .form-error-message { color: red; }
|
||||
.textwidget .contact-form input[type='text'], .textwidget .contact-form input[type='email'], .textwidget .contact-form textarea { width: 250px; max-width: 100%; box-sizing: border-box; }
|
||||
#jetpack-check-feedback-spam { margin: 1px 0px 0px 8px; }
|
||||
.jetpack-check-feedback-spam-spinner { display: inline-block; margin-top: 7px; }
|
|
@ -0,0 +1,75 @@
|
|||
/* This file was automatically generated on Oct 02 2015 21:49:32 */
|
||||
|
||||
#menu-posts-feedback .wp-menu-image img {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
#adminmenu .menu-icon-feedback div.wp-menu-image:before {
|
||||
content: '\f175';
|
||||
margin-right: -1px;
|
||||
}
|
||||
|
||||
.jetpack-contact-form-icon:before {
|
||||
content: '\f175';
|
||||
color: #888;
|
||||
vertical-align: text-bottom;
|
||||
font: normal 18px/1 'dashicons';
|
||||
speak: none;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image {
|
||||
background: url(../../images/grunion-menu-hover.png) no-repeat 7px 7px !important;
|
||||
background-size: 15px 16px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background: url(../../images/grunion-menu.png) no-repeat 7px 7px !important;
|
||||
background-size: 15px 16px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon {
|
||||
background: url(../../images/grunion-form.png) no-repeat;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-size: 13px 12px !important;
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media only screen and (min--moz-device-pixel-ratio: 1.5),
|
||||
only screen and (-o-min-device-pixel-ratio: 3/2),
|
||||
only screen and (-webkit-min-device-pixel-ratio: 1.5),
|
||||
only screen and (min-device-pixel-ratio: 1.5) {
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback:hover div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.wp-has-current-submenu div.wp-menu-image,
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback.current div.wp-menu-image {
|
||||
background-image: url(../../images/grunion-menu-hover-2x.png);
|
||||
}
|
||||
|
||||
.pre-mp6 #adminmenu .menu-icon-feedback div.wp-menu-image {
|
||||
background-image: url(../../images/grunion-menu-2x.png);
|
||||
}
|
||||
|
||||
.pre-mp6 .jetpack-contact-form-icon {
|
||||
background-image: url(../../images/grunion-form-2x.png);
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
}
|
2470
plugins/jetpack/modules/contact-form/grunion-contact-form.php
Normal file
242
plugins/jetpack/modules/contact-form/grunion-form-view.php
Normal file
|
@ -0,0 +1,242 @@
|
|||
<?php
|
||||
/**
|
||||
* Template for form builder
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filter to modify the limit of 5 additional contact form fields.
|
||||
*
|
||||
* @module contact-form
|
||||
*
|
||||
* @since 3.2.0
|
||||
*
|
||||
* @param int 5 Maximum number of additional fields.
|
||||
*/
|
||||
$max_new_fields = apply_filters( 'grunion_max_new_fields', 5 );
|
||||
|
||||
wp_register_script( 'grunion', GRUNION_PLUGIN_URL . 'js/grunion.js', array( 'jquery-ui-sortable', 'jquery-ui-draggable' ), JETPACK__VERSION );
|
||||
wp_localize_script( 'grunion', 'GrunionFB_i18n', array(
|
||||
'nameLabel' => esc_attr( _x( 'Name', 'Label for HTML form "Name" field in contact form builder', 'jetpack' ) ),
|
||||
'emailLabel' => esc_attr( _x( 'Email', 'Label for HTML form "Email" field in contact form builder', 'jetpack' ) ),
|
||||
'urlLabel' => esc_attr( _x( 'Website', 'Label for HTML form "URL/Website" field in contact form builder', 'jetpack' ) ),
|
||||
'commentLabel' => esc_attr( _x( 'Comment', 'noun', 'jetpack' ) ),
|
||||
'newLabel' => esc_attr( _x( 'New Field', 'Default label for new HTML form field in contact form builder', 'jetpack' ) ),
|
||||
'optionsLabel' => esc_attr( _x( 'Options', 'Label for the set of options to be included in a user-created dropdown in contact form builder', 'jetpack' ) ),
|
||||
'optionsLabel' => esc_attr( _x( 'Option', 'Label for an option to be included in a user-created dropdown in contact form builder', 'jetpack' ) ),
|
||||
'firstOptionLabel' => esc_attr( _x( 'First option', 'Default label for the first option to be included in a user-created dropdown in contact form builder', 'jetpack' ) ),
|
||||
'problemGeneratingForm' => esc_attr( _x( "Oops, there was a problem generating your form. You'll likely need to try again.", 'error message in contact form builder', 'jetpack' ) ),
|
||||
'moveInstructions' => esc_attr__( "Drag up or down\nto re-arrange", 'jetpack' ),
|
||||
'moveLabel' => esc_attr( _x( 'move', 'Label to drag HTML form fields around to change their order in contact form builder', 'jetpack' ) ),
|
||||
'editLabel' => esc_attr( _x( 'edit', 'Link to edit an HTML form field in contact form builder', 'jetpack' ) ),
|
||||
'savedMessage' => esc_attr__( 'Saved successfully', 'jetpack' ),
|
||||
'requiredLabel' => esc_attr( _x( '(required)', 'This HTML form field is marked as required by the user in contact form builder', 'jetpack' ) ),
|
||||
'exitConfirmMessage' => esc_attr__( 'Are you sure you want to exit the form editor without saving? Any changes you have made will be lost.', 'jetpack' ),
|
||||
'maxNewFields' => intval( $max_new_fields ),
|
||||
) );
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title><?php esc_html_e( 'Contact Form', 'jetpack' ); ?></title>
|
||||
<script type="text/javascript">
|
||||
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
|
||||
var postId = <?php echo absint( $_GET['post_id'] ); ?>;
|
||||
var ajax_nonce_shortcode = '<?php echo wp_create_nonce( 'grunion_shortcode' ); ?>';
|
||||
var ajax_nonce_json = '<?php echo wp_create_nonce( 'grunion_shortcode_to_json' ); ?>';
|
||||
</script>
|
||||
<?php wp_print_scripts( 'grunion' ); ?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function () {
|
||||
FB.ContactForm.init();
|
||||
FB.ContactForm.resizePop();
|
||||
});
|
||||
jQuery(window).resize(function() {
|
||||
setTimeout(function () { FB.ContactForm.resizePop(); }, 50);
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
/* Reset */
|
||||
html { height: 100%; }
|
||||
body, div, ul, ol, li, h1, h2, h3, h4, h5, h6, form, fieldset, legend, input, button, textarea, p, blockquote, th, td { margin: 0; padding: 0; }
|
||||
body { background: #F9F9F9; font-family:"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif; font-size:12px; color: #333; line-height:1.5em; height: 100%; width: 100%; padding-bottom: 20px !important; }
|
||||
a { color: #21759B; text-decoration: none; }
|
||||
a:hover { text-decoration: underline; text-shadow: none !important; }
|
||||
h1 { font-size: 21px; color:#5A5A5A; font-family:Georgia,"Times New Roman",Times,serif; font-weight:normal; margin-bottom: 21px; }
|
||||
h3 { font-size: 13px; color: #666; margin-bottom: 18px; }
|
||||
input { width: 301px; }
|
||||
input[type='text'] { padding: 3px 5px; margin-right: 4px; -moz-border-radius:3px; border-radius:3px; -webkit-border-radius:3px; }
|
||||
input[type='text']:focus { border: 2px solid #80B8D9; outline: 0 !important; }
|
||||
input[type='checkbox'], input[type='radio'] { width: auto !important; float: left; margin-top: 3px; margin-right: 8px; }
|
||||
input.fieldError, select.fieldError, textarea.fieldError { border: 2px solid #D56F55; }
|
||||
img { border: none; }
|
||||
label { color: #222; font-weight: bold; display: block; margin-bottom: 4px; }
|
||||
label.radio { width: auto; margin: -2px 0 0 5px; }
|
||||
label span.label-required { color: #AAA; margin-left: 4px; font-weight: normal; }
|
||||
td { vertical-align: top; }
|
||||
select { width: 300px; }
|
||||
textarea { height: 100px; width: 311px; }
|
||||
/* Core */
|
||||
#media-upload-header { border-bottom: 1px solid #DFDFDF; font-weight:bold; margin:0; padding:3px 5px 0 5px; position:relative; background: #FFF; }
|
||||
#sidemenu { bottom:-1px; font-size:12px; list-style:none outside none; padding-left:10px; position:relative; left:0; margin:0 5px; overflow:hidden; }
|
||||
#sidemenu a { text-decoration:none; border-top: 1px solid #FFF; display:block; float:left; line-height:28px; padding:0 13px; outline: none; }
|
||||
#sidemenu a.current { background-color:#F9F9F9; border-color:#DFDFDF #DFDFDF #F9F9F9; color:#D54E21; -moz-border-radius:4px 4px 0 0; border-radius:4px 4px 0 0; -webkit-border-radius:4px 4px 0 0; border-style:solid; border-width:1px; font-weight:normal; }
|
||||
#sidemenu li { display:inline; margin-bottom:6px; line-height:200%; list-style:none outside none; margin:0; padding:0; text-align:center; white-space:nowrap; }
|
||||
.button { background-color:#f2f2f2; border-color:#BBBBBB; min-width:80px; text-align:center; color:#464646; text-shadow:0 1px 0 #FFFFFF; border-style:solid; border-width:1px; cursor:pointer; width: auto; font-size:11px !important; line-height:13px; padding:3px 11px; margin-top: 12px; text-decoration:none; -moz-border-radius:11px; border-radius:11px; -webkit-border-radius:11px }
|
||||
.button-primary { background-color:#21759B; font-weight: bold; border-color:#298CBA; text-align:center; color:#EAF2FA; text-shadow:0 -1px 0 rgba(0, 0, 0, 0.3); border-style:solid; border-width:1px; cursor:pointer; width: auto; font-size:11px !important; line-height:13px; padding:3px 11px; margin-top: 21px; text-decoration:none; -moz-border-radius:11px; border-radius:11px; -webkit-border-radius:11px }
|
||||
.clear { clear: both; }
|
||||
.fb-add-field { padding-left: 10px; }
|
||||
.fb-add-option { margin: 0 0 14px 100px; }
|
||||
.fb-container { margin: 21px; padding-bottom: 20px; }
|
||||
.fb-desc, #fb-add-field { margin-top: 34px; }
|
||||
.fb-extra-fields { margin-bottom: 2px; }
|
||||
.fb-form-case { background: #FFF; padding: 13px; border: 1px solid #E2E2E2; width: 336px; -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px }
|
||||
.fb-form-case a { outline: none; }
|
||||
.fb-form-case input[type='text'], .fb-form-case textarea { background: #E1E1E1; }
|
||||
.fb-radio-label { display: inline-block; float: left; width: 290px; }
|
||||
.fb-new-fields { position: relative; border: 1px dashed #FFF; background: #FFF; padding: 4px 10px 10px; cursor: default; }
|
||||
.fb-new-fields:hover { border: 1px dashed #BBDBEA; background: #F7FBFD; }
|
||||
.fb-options { width: 170px !important; }
|
||||
.fb-remove { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-field.gif') no-repeat; position: absolute; cursor: pointer !important; right: -26px; top: 27px; width: 20px; height: 23px; }
|
||||
.fb-remove:hover { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-field-hover.gif') no-repeat; }
|
||||
.fb-remove-small { top: 2px !important; }
|
||||
.fb-remove-option { position: absolute; top: 1px; right: 10px; width: 20px; height: 23px; background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-option.gif') no-repeat; }
|
||||
.fb-remove-option:hover { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-option-hover.gif') no-repeat; }
|
||||
.fb-reorder { cursor: move; position: relative; }
|
||||
.fb-reorder:hover div { display: block !important; width: 130px !important; position: absolute; top: 0; right: 0; z-index: 200; padding: 5px 10px; color: #555; font-size: 11px; background: #FFF; border: 1px solid #CCC; -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; }
|
||||
.fb-right { position: absolute; right: 0; top: 0; width: 315px; margin: 57px 21px 0 0; }
|
||||
.fb-right .fb-new-fields { border: none; background: #F9F9F9; padding: 0; }
|
||||
.fb-right input[type='text'] { width: 195px; margin-bottom: 14px; }
|
||||
.fb-right label { color: #444; width: 100px; float: left; font-weight: normal; }
|
||||
.fb-right select { width: 195px !important; margin-bottom: 14px; }
|
||||
.fb-right textarea { margin-bottom: 13px; }
|
||||
.fb-right p { color: #999; line-height: 19px; }
|
||||
.fb-settings input[type='text'], .fb-settings textarea { background-image: none !important; }
|
||||
.fb-success { position: absolute; top: -3px; right: 100px; padding: 6px 23px 4px 23px; background: #FFFFE0; font-weight: normal; border: 1px solid #E6DB55; color: #333; -moz-border-radius:4px; border-radius:4px; -webkit-border-radius:4px; }
|
||||
.right { float: right; }
|
||||
/* rtl */
|
||||
body.rtl{ direction: rtl; font-family:Tahoma,Arial,sans-serif}
|
||||
.rtl input[type='text'] { margin-left: 4px; margin-right: 0; }
|
||||
.rtl input[type='checkbox'], .rtl input[type='radio'] { float: right; }
|
||||
.rtl input[type='radio'] { margin-left: 8px; margin-right: 0; }
|
||||
.rtl label.radio { margin: -2px 5px 0 0; }
|
||||
.rtl label span.label-required { margin-right: 4px; margin-left:0 }
|
||||
.rtl #sidemenu { padding-right:10px; padding-left: 0; left:auto; right: 0; }
|
||||
.rtl #sidemenu a { float:right; }
|
||||
.rtl .fb-add-field { padding-right: 10px; padding-left: 0; }
|
||||
.rtl .fb-add-option { margin: 0 100px 14px 0; }
|
||||
.rtl .fb-radio-label { margin-right: 8px; margin-left: 0; float: right; }
|
||||
.rtl .fb-remove { right: auto; left: -26px; transform: scaleX(-1); }
|
||||
.rtl .fb-remove-option { right: auto; left: 10px; }
|
||||
.rtl .fb-reorder:hover div { left: 0; right: auto; }
|
||||
.rtl .fb-right { left: 0; right: auto; margin: 57px 0 0 21px; }
|
||||
.rtl .fb-right label { float: right; }
|
||||
.rtl .fb-success { right: auto; left: 100px;}
|
||||
.rtl .right { float: left; }
|
||||
@media only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
|
||||
.fb-remove { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-field-2x.png') no-repeat; background-size: 20px 23px; }
|
||||
.fb-remove:hover { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-field-hover-2x.png') no-repeat; background-size: 20px 23px; }
|
||||
.fb-remove-option { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-option-2x.png') no-repeat; background-size: 20px 23px; }
|
||||
.fb-remove-option:hover { background: url('<?php echo GRUNION_PLUGIN_URL; ?>/images/grunion-remove-option-hover-2x.png') no-repeat; background-size: 20px 23px; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body <?php if ( is_rtl() ) { echo 'class="rtl"'; }?>>
|
||||
<div id="media-upload-header">
|
||||
<div id="fb-success" class="fb-success" style="display: none;"><?php esc_html_e( 'Your new field was saved successfully', 'jetpack' ); ?></div>
|
||||
<ul id="sidemenu">
|
||||
<li id="tab-preview"><a class="current" href=""><?php esc_html_e( 'Form builder', 'jetpack' ); ?></a></li>
|
||||
<li id="tab-settings"><a href=""><?php esc_html_e( 'Email notifications', 'jetpack' ); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="fb-right">
|
||||
<div id="fb-desc" class="fb-desc">
|
||||
<h3><?php esc_html_e( 'How does this work?', 'jetpack' ); ?></h3>
|
||||
<p><?php esc_html_e( 'By adding a contact form, your readers will be able to submit feedback to you. All feedback is automatically scanned for spam, and the legitimate feedback will be emailed to you.', 'jetpack' ); ?></p>
|
||||
<h3 style="margin-top: 21px;"><?php esc_html_e( 'Can I add more fields?', 'jetpack' ); ?></h3>
|
||||
<p><?php printf(
|
||||
esc_html( _x( 'Sure thing. %1$s to add a new text box, textarea, radio, checkbox, or dropdown field.', '%1$s = "Click here" in an HTML link', 'jetpack' ) ),
|
||||
'<a href="#" class="fb-add-field" style="padding-left: 0;">' . esc_html__( 'Click here', 'jetpack' ) . '</a>'
|
||||
); ?></p>
|
||||
<h3 style="margin-top: 21px;"><?php esc_html_e( 'Can I view my feedback within WordPress?', 'jetpack' ); ?></h3>
|
||||
<p><?php printf(
|
||||
esc_html( _x( 'Yep, you can read your feedback at any time by clicking the "%1$s" link in the admin menu.', '%1$s = "Feedback" in an HTML link', 'jetpack' ) ),
|
||||
'<a id="fb-feedback" href="' . admin_url( 'edit.php?post_type=feedback' ) . '">' . esc_html__( 'Feedback', 'jetpack' ) . '</a>'
|
||||
); ?></p>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div id="fb-email-desc" class="fb-desc" style="display: none;">
|
||||
<h3><?php esc_html_e( 'Do I need to fill this out?', 'jetpack' ); ?></h3>
|
||||
<p><?php esc_html_e( 'Nope. However, if you’d like to modify where your feedback is sent, or the subject line you can. If you don’t make any changes here, feedback will be sent to the author of the page/post and the subject will be the name of this page/post.', 'jetpack' ); ?></p>
|
||||
<h3 style="margin-top: 21px;"><?php esc_html_e( 'Can I send a notification to more than one person?', 'jetpack' ); ?></h3>
|
||||
<p><?php esc_html_e( 'Yep. You can enter multiple email addresses in the Email address field, and separate them with commas. A notification email will then be sent to each email address.', 'jetpack' ); ?></p>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<div id="fb-add-field" style="display: none;">
|
||||
<h3><?php esc_html_e( 'Edit this new field', 'jetpack' ); ?></h3>
|
||||
|
||||
<label for="fb-new-label"><?php esc_html_e( 'Label', 'jetpack' ); ?></label>
|
||||
<input type="text" id="fb-new-label" value="<?php esc_attr_e( 'New field', 'jetpack' ); ?>" />
|
||||
|
||||
<label for="fb-new-label"><?php esc_html_e( 'Field type', 'jetpack' ); ?></label>
|
||||
<select id="fb-new-type">
|
||||
<option value="checkbox"><?php esc_html_e( 'Checkbox', 'jetpack' ); ?></option>
|
||||
<option value="checkbox-multiple"><?php esc_html_e( 'Checkbox with Multiple Items', 'jetpack' ); ?></option>
|
||||
<option value="select"><?php esc_html_e( 'Drop down', 'jetpack' ); ?></option>
|
||||
<option value="email"><?php esc_html_e( 'Email', 'jetpack' ); ?></option>
|
||||
<option value="name"><?php esc_html_e( 'Name', 'jetpack' ); ?></option>
|
||||
<option value="radio"><?php esc_html_e( 'Radio', 'jetpack' ); ?></option>
|
||||
<option value="text" selected="selected"><?php esc_html_e( 'Text', 'jetpack' ); ?></option>
|
||||
<option value="textarea"><?php esc_html_e( 'Textarea', 'jetpack' ); ?></option>
|
||||
<option value="url"><?php esc_html_e( 'Website', 'jetpack' ); ?></option>
|
||||
</select>
|
||||
<div class="clear"></div>
|
||||
|
||||
<div id="fb-options" style="display: none;">
|
||||
<div id="fb-new-options">
|
||||
<label for="fb-option0"><?php esc_html_e( 'Options', 'jetpack' ); ?></label>
|
||||
<input type="text" id="fb-option0" optionid="0" value="<?php esc_attr_e( 'First option', 'jetpack' ); ?>" class="fb-options" />
|
||||
</div>
|
||||
<div id="fb-add-option" class="fb-add-option">
|
||||
<a href="#" id="fb-another-option"><?php esc_html_e( 'Add another option', 'jetpack' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fb-required">
|
||||
<label for="fb-new-label"></label>
|
||||
<input type="checkbox" id="fb-new-required" />
|
||||
<label for="fb-new-label" class="fb-radio-label"><?php esc_html_e( 'Required?', 'jetpack' ); ?></label>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="fb-field-id" />
|
||||
<input type="submit" class="button" value="<?php esc_attr_e( 'Save this field', 'jetpack' ); ?>" id="fb-save-field" name="save">
|
||||
</div>
|
||||
</div>
|
||||
<form id="fb-preview">
|
||||
<div id="fb-preview-form" class="fb-container">
|
||||
<h1><?php esc_html_e( 'Here’s what your form will look like', 'jetpack' ); ?></h1>
|
||||
<div id="sortable" class="fb-form-case">
|
||||
|
||||
<div id="fb-extra-fields" class="fb-extra-fields"></div>
|
||||
|
||||
<a href="#" id="fb-new-field" class="fb-add-field"><?php esc_html_e( 'Add a new field', 'jetpack' ); ?></a>
|
||||
</div>
|
||||
<input type="submit" class="button-primary" tabindex="4" value="<?php esc_attr_e( 'Add this form to my post', 'jetpack' ); ?>" id="fb-save-form" name="save">
|
||||
</div>
|
||||
<div id="fb-email-settings" class="fb-container" style="display: none;">
|
||||
<h1><?php esc_html_e( 'Email settings', 'jetpack' ); ?></h1>
|
||||
<div class="fb-form-case fb-settings">
|
||||
<label for="fb-fieldname"><?php esc_html_e( 'Enter your email address', 'jetpack' ); ?></label>
|
||||
<input type="text" id="fb-field-my-email" style="background: #FFF !important;" />
|
||||
|
||||
<label for="fb-fieldemail" style="margin-top: 14px;"><?php esc_html_e( 'What should the subject line be?', 'jetpack' ); ?></label>
|
||||
<input type="text" id="fb-field-subject" style="background: #FFF !important;" />
|
||||
</div>
|
||||
<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save and go back to form builder', 'jetpack' ); ?>" id="fb-prev-form" name="save">
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
83
plugins/jetpack/modules/contact-form/grunion-omnisearch.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
if( ! class_exists( 'WP_List_Table' ) )
|
||||
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
||||
|
||||
class Jetpack_Omnisearch_Grunion extends WP_List_Table {
|
||||
static $instance;
|
||||
public $post_type = 'feedback';
|
||||
|
||||
function __construct() {
|
||||
self::$instance = $this;
|
||||
add_filter( 'omnisearch_results', array( $this, 'search'), 12, 2 );
|
||||
|
||||
// Push 'post_type_obj' to accepted fields for WP_List_Table (since WP 4.2)
|
||||
global $wp_version;
|
||||
if ( version_compare( $wp_version, '4.2-z', '>=' ) && $this->compat_fields && is_array( $this->compat_fields ) ) {
|
||||
array_push( $this->compat_fields, 'post_type_obj' );
|
||||
}
|
||||
}
|
||||
|
||||
function search( $results, $search_term ) {
|
||||
parent::__construct();
|
||||
|
||||
$this->post_type_obj = get_post_type_object( $this->post_type );
|
||||
|
||||
$search_url = esc_url( admin_url( sprintf( 'edit.php?post_type=%s&s=%s', urlencode( $this->post_type_obj->name ), urlencode( $search_term ) ) ) );
|
||||
$search_link = sprintf( ' <a href="%s" class="add-new-h2">%s</a>', $search_url, esc_html( $this->post_type_obj->labels->search_items ) );
|
||||
$html = '<h2>' . esc_html( $this->post_type_obj->labels->name ) . $search_link .'</h2>';
|
||||
|
||||
$this->prepare_items( $search_term );
|
||||
|
||||
ob_start();
|
||||
$this->display();
|
||||
$html .= ob_get_clean();
|
||||
|
||||
$results[ $this->post_type_obj->labels->name ] = $html;
|
||||
return $results;
|
||||
}
|
||||
|
||||
function get_columns() {
|
||||
$columns = array(
|
||||
'feedback_from' => __('From', 'jetpack'),
|
||||
'feedback_message' => __('Message', 'jetpack'),
|
||||
'feedback_date' => __('Date', 'jetpack'),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
function prepare_items( $search_term = '' ) {
|
||||
$this->_column_headers = array( $this->get_columns(), array(), array() );
|
||||
/** This action is documented in modules/omnisearch/omnisearch-core.php */
|
||||
$num_results = apply_filters( 'omnisearch_num_results', 5 );
|
||||
$this->items = get_posts( array(
|
||||
's' => $search_term,
|
||||
'post_type' => $this->post_type,
|
||||
'posts_per_page' => $num_results,
|
||||
) );
|
||||
}
|
||||
|
||||
function column_default( $post, $column_name ) {
|
||||
// Make sure the global $post is our post.
|
||||
$_post = $GLOBALS['post'];
|
||||
$GLOBALS['post'] = $post;
|
||||
setup_postdata( $post );
|
||||
|
||||
switch ( $column_name ) {
|
||||
case 'feedback_from':
|
||||
case 'feedback_message':
|
||||
case 'feedback_date':
|
||||
ob_start();
|
||||
grunion_manage_post_columns( $column_name, $post->ID );
|
||||
$column_contents = ob_get_clean();
|
||||
break;
|
||||
default:
|
||||
$column_contents = '<pre>' . print_r( $post, true ) . '</pre>';
|
||||
break;
|
||||
}
|
||||
|
||||
$GLOBALS['post'] = $_post;
|
||||
wp_reset_postdata();
|
||||
return $column_contents;
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.8 KiB |
BIN
plugins/jetpack/modules/contact-form/images/grunion-form-2x.png
Normal file
After Width: | Height: | Size: 153 B |
BIN
plugins/jetpack/modules/contact-form/images/grunion-form.png
Normal file
After Width: | Height: | Size: 188 B |
BIN
plugins/jetpack/modules/contact-form/images/grunion-menu-2x.png
Normal file
After Width: | Height: | Size: 546 B |
After Width: | Height: | Size: 340 B |
BIN
plugins/jetpack/modules/contact-form/images/grunion-menu-big.png
Normal file
After Width: | Height: | Size: 352 B |
After Width: | Height: | Size: 611 B |
After Width: | Height: | Size: 278 B |
BIN
plugins/jetpack/modules/contact-form/images/grunion-menu.png
Normal file
After Width: | Height: | Size: 157 B |
After Width: | Height: | Size: 201 B |
After Width: | Height: | Size: 207 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 139 B |
After Width: | Height: | Size: 99 B |
After Width: | Height: | Size: 94 B |
After Width: | Height: | Size: 73 B |
After Width: | Height: | Size: 73 B |
29
plugins/jetpack/modules/contact-form/js/grunion-admin.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* global ajaxurl */
|
||||
jQuery( function ( $ ) {
|
||||
$( document ).on( 'click', '#jetpack-check-feedback-spam:not(.button-disabled)', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '#jetpack-check-feedback-spam:not(.button-disabled)' ).addClass( 'button-disabled' );
|
||||
$( '.jetpack-check-feedback-spam-spinner' ).addClass( 'spinner' ).show();
|
||||
grunion_check_for_spam( 0, 100 );
|
||||
} );
|
||||
|
||||
function grunion_check_for_spam( offset, limit ) {
|
||||
$.post(
|
||||
ajaxurl,
|
||||
{
|
||||
'action' : 'grunion_recheck_queue',
|
||||
'offset' : offset,
|
||||
'limit' : limit
|
||||
},
|
||||
function ( result ) {
|
||||
if ( result.processed < limit ) {
|
||||
window.location.reload();
|
||||
}
|
||||
else {
|
||||
grunion_check_for_spam( offset + limit, limit );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
} );
|
|
@ -0,0 +1,5 @@
|
|||
jQuery( function ( $ ) {
|
||||
if ( 'function' === typeof $.fn.datepicker ) {
|
||||
$( '.contact-form input[type="date"]' ).datepicker( { dateFormat : 'yy-mm-dd' } );
|
||||
}
|
||||
} );
|
813
plugins/jetpack/modules/contact-form/js/grunion.js
Normal file
|
@ -0,0 +1,813 @@
|
|||
/* jshint onevar: false, devel: true, smarttabs: true */
|
||||
/* global GrunionFB_i18n: true, FB, ajax_nonce_shortcode, ajax_nonce_json, ajaxurl, postId */
|
||||
|
||||
if ( ! window.FB ) {
|
||||
window.FB = {};
|
||||
}
|
||||
|
||||
GrunionFB_i18n = jQuery.extend( {
|
||||
nameLabel: 'Name',
|
||||
emailLabel: 'Email',
|
||||
urlLabel: 'Website',
|
||||
commentLabel: 'Comment',
|
||||
newLabel: 'New Field',
|
||||
optionsLabel: 'Options',
|
||||
optionLabel: 'Option',
|
||||
firstOptionLabel: 'First option',
|
||||
problemGeneratingForm: 'Oops, there was a problem generating your form. You\'ll likely need to try again.',
|
||||
moveInstructions: 'Drag up or down\nto re-arrange',
|
||||
moveLabel: 'move',
|
||||
editLabel: 'edit',
|
||||
savedMessage: 'Saved successfully',
|
||||
requiredLabel: '(required)',
|
||||
exitConfirmMessage: 'Are you sure you want to exit the form editor without saving? Any changes you have made will be lost.',
|
||||
maxNewFields: 5,
|
||||
invalidEmail: ' is an invalid email address.'
|
||||
}, GrunionFB_i18n );
|
||||
|
||||
GrunionFB_i18n.moveInstructions = GrunionFB_i18n.moveInstructions.replace( '\n', '<br />' );
|
||||
|
||||
FB.span = jQuery( '<span>' );
|
||||
FB.esc_html = function( string ) {
|
||||
return FB.span.text( string ).html();
|
||||
};
|
||||
|
||||
FB.esc_attr = function( string ) {
|
||||
string = FB.esc_html( string );
|
||||
return string.replace( '"', '"' ).replace( '\'', ''' );
|
||||
};
|
||||
|
||||
FB.ContactForm = (function() {
|
||||
var fbForm = { // Main object that generated shortcode via AJAX call
|
||||
'action' : 'grunion_shortcode',
|
||||
'_ajax_nonce' : ajax_nonce_shortcode,
|
||||
'to' : '',
|
||||
'subject' : '',
|
||||
'fields' : {}
|
||||
};
|
||||
var defaultFields = {
|
||||
'name': {
|
||||
'label' : GrunionFB_i18n.nameLabel,
|
||||
'type' : 'name',
|
||||
'required' : true,
|
||||
'options' : [],
|
||||
'order' : '1'
|
||||
},
|
||||
'email': {
|
||||
'label' : GrunionFB_i18n.emailLabel,
|
||||
'type' : 'email',
|
||||
'required' : true,
|
||||
'options' : [],
|
||||
'order' : '2'
|
||||
},
|
||||
'url': {
|
||||
'label' : GrunionFB_i18n.urlLabel,
|
||||
'type' : 'url',
|
||||
'required' : false,
|
||||
'options' : [],
|
||||
'order' : '3'
|
||||
},
|
||||
'comment': {
|
||||
'label' : GrunionFB_i18n.commentLabel,
|
||||
'type' : 'textarea',
|
||||
'required' : true,
|
||||
'options' : [],
|
||||
'order' : '4'
|
||||
}
|
||||
};
|
||||
var debug = false; // will print errors to log if true
|
||||
var grunionNewCount = 0; // increment for new fields
|
||||
var maxNewFields = GrunionFB_i18n.maxNewFields; // See filter in ../grunion-form-view.php
|
||||
var optionsCache = {};
|
||||
var optionsCount = 0; // increment for options
|
||||
var shortcode;
|
||||
|
||||
function addField () {
|
||||
try {
|
||||
grunionNewCount++;
|
||||
if (grunionNewCount <= maxNewFields) {
|
||||
// Add to preview
|
||||
jQuery('#fb-extra-fields').append('<div id="fb-new-field' + grunionNewCount + '" fieldid="' + grunionNewCount + '" class="fb-new-fields"><div class="fb-fields"><div id="' + grunionNewCount + '" class="fb-remove"></div><label fieldid="' + grunionNewCount + '" for="fb-field' + grunionNewCount + '"><span class="label-text">' + GrunionFB_i18n.newLabel + '</span> </label><input type="text" id="fb-field' + grunionNewCount + '" disabled="disabled" /></div></div>');
|
||||
// Add to form object
|
||||
fbForm.fields[grunionNewCount] = {
|
||||
'label' : GrunionFB_i18n.newLabel,
|
||||
'type' : 'text',
|
||||
'required' : false,
|
||||
'options' : [],
|
||||
'order' : '5'
|
||||
};
|
||||
if (grunionNewCount === maxNewFields) {
|
||||
jQuery('#fb-new-field').hide();
|
||||
}
|
||||
// Reset form for this new field
|
||||
optionsCount = 0;
|
||||
optionsCache = {};
|
||||
jQuery('#fb-new-options').html('<label for="fb-option0">' + GrunionFB_i18n.optionsLabel + '</label><input type="text" id="fb-option0" optionid="0" value="' + GrunionFB_i18n.firstOptionLabel + '" class="fb-options" />');
|
||||
jQuery('#fb-options').hide();
|
||||
jQuery('#fb-new-label').val( GrunionFB_i18n.newLabel );
|
||||
jQuery('#fb-new-type').val('text');
|
||||
jQuery('#fb-field-id').val(grunionNewCount);
|
||||
setTimeout(function () { jQuery('#fb-new-label').focus().select(); }, 100);
|
||||
} else {
|
||||
jQuery('#fb-new-field').hide();
|
||||
}
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('addField(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function addOption () {
|
||||
try {
|
||||
optionsCount = jQuery( '#fb-new-options .fb-options' ).length;
|
||||
var thisId = jQuery('#fb-field-id').val();
|
||||
var thisType = jQuery('#fb-new-type').val();
|
||||
if (thisType === 'radio') {
|
||||
// Add to right col
|
||||
jQuery('#fb-new-options').append('<div id="fb-option-box-' + optionsCount + '" class="fb-new-fields"><span optionid="' + optionsCount + '" class="fb-remove-option"></span><label></label><input type="text" id="fb-option' + optionsCount + '" optionid="' + optionsCount + '" value="' + GrunionFB_i18n.optionLabel + '" class="fb-options" /><div>');
|
||||
// Add to preview
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').append('<div id="fb-radio-' + thisId + '-' + optionsCount + '"><input type="radio" disabled="disabled" id="fb-field' + thisId + '" name="radio-' + thisId + '" /><span>' + GrunionFB_i18n.optionLabel + '</span><div class="clear"></div></div>');
|
||||
} else if ( 'checkbox-multiple' === thisType ) {
|
||||
// Add to right col
|
||||
jQuery('#fb-new-options').append('<div id="fb-option-box-' + optionsCount + '" class="fb-new-fields"><span optionid="' + optionsCount + '" class="fb-remove-option"></span><label></label><input type="text" id="fb-option' + optionsCount + '" optionid="' + optionsCount + '" value="' + GrunionFB_i18n.optionLabel + '" class="fb-options" /><div>');
|
||||
// Add to preview
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').append('<div id="fb-checkbox-multiple-' + thisId + '-' + optionsCount + '"><input type="checkbox" disabled="disabled" id="fb-field' + thisId + '" name="checkbox-multiple-' + thisId + '" /><span>' + GrunionFB_i18n.optionLabel + '</span><div class="clear"></div></div>');
|
||||
} else {
|
||||
// Add to right col
|
||||
jQuery('#fb-new-options').append('<div id="fb-option-box-' + optionsCount + '" class="fb-new-fields"><span optionid="' + optionsCount + '" class="fb-remove-option"></span><label></label><input type="text" id="fb-option' + optionsCount + '" optionid="' + optionsCount + '" value="" class="fb-options" /><div>');
|
||||
// Add to preview
|
||||
jQuery('#fb-field'+ thisId).append('<option id="fb-' + thisId + '-' + optionsCount + '" value="' + thisId + '-' + optionsCount + '"></option>');
|
||||
}
|
||||
// Add to fbForm object
|
||||
fbForm.fields[thisId].options[optionsCount] = '';
|
||||
// Add focus to new field
|
||||
jQuery('#fb-option' + optionsCount).focus().select();
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('addOption(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function buildPreview () {
|
||||
try {
|
||||
if (fbForm.to) { jQuery('#fb-field-my-email').val(fbForm.to); }
|
||||
if (fbForm.subject) { jQuery('#fb-field-subject').val(fbForm.subject); }
|
||||
// Loop over and add fields
|
||||
jQuery.each(fbForm.fields, function(index, value) {
|
||||
jQuery('#fb-extra-fields').before('<div class="fb-new-fields ui-state-default" fieldid="' + index + '" id="fb-new-field' + index + '"><div class="fb-fields"></div></div>');
|
||||
jQuery('#fb-field-id').val(index);
|
||||
optionsCache[index] = {};
|
||||
optionsCache[index].options = [];
|
||||
if ( 'radio' === value.type || 'select' === value.type || 'checkbox-multiple' === value.type ) {
|
||||
jQuery.each(value.options, function(i, value) {
|
||||
optionsCache[index].options[i] = value;
|
||||
});
|
||||
}
|
||||
updateType(value.type, value.label, value.required);
|
||||
});
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('buildPreview(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function customOptions (id, thisType) {
|
||||
try {
|
||||
var thisOptions = '';
|
||||
for (var i=0; i<optionsCache[id].options.length; i++) {
|
||||
if (optionsCache[id].options[i] !== undefined) {
|
||||
if (thisType === 'radio') {
|
||||
thisOptions = thisOptions + '<div id="fb-radio-' + id + '-' + i + '"><input type="radio" id="fb-field' + id + '" name="radio-' + id + '" /><span>' + FB.esc_html( optionsCache[id].options[i] ) + '</span><div class="clear"></div></div>';
|
||||
} else if ( 'checkbox-multiple' === thisType ) {
|
||||
thisOptions = thisOptions + '<div id="fb-checkbox-multiple-' + id + '-' + i + '"><input type="checkbox" id="fb-field' + id + '" name="checkbox-multiple-' + id + '" /><span>' + FB.esc_html( optionsCache[id].options[i] ) + '</span><div class="clear"></div></div>';
|
||||
} else {
|
||||
thisOptions = thisOptions + '<option id="fb-' + id + '-' + i + '" value="' + id + '-' + i + '">' + FB.esc_html( optionsCache[id].options[i] ) + '</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
return thisOptions;
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('customOptions(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function deleteField (that) {
|
||||
try {
|
||||
grunionNewCount--;
|
||||
var thisId = that.attr('id');
|
||||
delete fbForm.fields[thisId];
|
||||
jQuery('#' + thisId).parent().parent().remove();
|
||||
if (grunionNewCount <= maxNewFields) {
|
||||
jQuery('#fb-new-field').show();
|
||||
}
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('deleteField(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function editField (that) {
|
||||
try {
|
||||
scroll(0,0);
|
||||
setTimeout(function () { jQuery('#fb-new-label').focus().select(); }, 100);
|
||||
var thisId = that.parent().attr('fieldid');
|
||||
loadFieldEditor(thisId);
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('editField(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function grabShortcode () {
|
||||
try {
|
||||
// Takes fbForm object and returns shortcode syntax
|
||||
jQuery.post(ajaxurl, fbForm, function(response) {
|
||||
shortcode = response;
|
||||
});
|
||||
} catch(e) {
|
||||
alert( GrunionFB_i18n.problemGeneratingForm );
|
||||
if (debug) {
|
||||
console.log('grabShortcode(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function hideDesc () {
|
||||
jQuery('#fb-desc').hide();
|
||||
jQuery('#fb-add-field').show();
|
||||
}
|
||||
function hidePopup () {
|
||||
try {
|
||||
// copied from wp-includes/js/thickbox/thickbox.js
|
||||
jQuery('#TB_imageOff', window.parent.document).unbind('click');
|
||||
jQuery('#TB_closeWindowButton', window.parent.document).unbind('click');
|
||||
jQuery('#TB_window', window.parent.document).fadeOut('fast');
|
||||
jQuery('body', window.parent.document).removeClass('modal-open');
|
||||
jQuery('#TB_window,#TB_overlay,#TB_HideSelect', window.parent.document).trigger('unload').unbind().remove();
|
||||
jQuery('#TB_load', window.parent.document).remove();
|
||||
if (typeof window.parent.document.body.style.maxHeight === 'undefined') {//if IE 6
|
||||
jQuery('body', 'html', window.parent.document).css({height: 'auto', width: 'auto'});
|
||||
jQuery('html', window.parent.document).css('overflow', '');
|
||||
}
|
||||
window.parent.document.onkeydown = '';
|
||||
window.parent.document.onkeyup = '';
|
||||
return false;
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('hidePopup(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function hideShowEditLink (whichType, that) {
|
||||
try {
|
||||
if (whichType === 'show') {
|
||||
// Prevents showing links twice
|
||||
if (jQuery('.fb-edit-field').is(':visible')) {
|
||||
jQuery('.fb-edit-field').remove();
|
||||
}
|
||||
that.find('label').prepend('<span class="right fb-edit-field" style="font-weight: normal;"><a href="" class="fb-reorder"><div style="display: none;">' + GrunionFB_i18n.moveInstructions + '</div>' + GrunionFB_i18n.moveLabel + '</a> <span style="color: #C7D8DE;">|</span> <a href="" class="fb-edit">' + GrunionFB_i18n.editLabel + '</a></span>');
|
||||
} else {
|
||||
jQuery('.fb-edit-field').remove();
|
||||
}
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('hideShowEditLink(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function loadFieldEditor (id) {
|
||||
try {
|
||||
var thisType = fbForm.fields[id].type;
|
||||
jQuery('#fb-options').hide();
|
||||
// Reset hidden field ID
|
||||
jQuery('#fb-field-id').val(id);
|
||||
// Load label
|
||||
jQuery('#fb-new-label').val(fbForm.fields[id].label);
|
||||
// Load type
|
||||
jQuery('#fb-new-type').val(fbForm.fields[id].type);
|
||||
// Load required
|
||||
if (fbForm.fields[id].required) {
|
||||
jQuery('#fb-new-required').prop('checked', true);
|
||||
} else {
|
||||
jQuery('#fb-new-required').prop('checked', false);
|
||||
}
|
||||
// Load options if there are any
|
||||
if ( 'select' === thisType || 'radio' === thisType || 'checkbox-multiple' === thisType ) {
|
||||
var thisOptions = fbForm.fields[id].options;
|
||||
jQuery('#fb-options').show();
|
||||
jQuery('#fb-new-options').html(''); // Clear it all out
|
||||
for (var i=0; i<thisOptions.length; i++) {
|
||||
if (thisOptions[i] !== undefined) {
|
||||
if (thisType === 'radio') {
|
||||
jQuery('#fb-new-options').append('<div id="fb-option-box-' + i + '" class="fb-new-fields"><span optionid="' + i + '" class="fb-remove-option"></span><label></label><input type="text" id="fb-option' + i + '" optionid="' + i + '" value="' + FB.esc_attr( fbForm.fields[id].options[i] ) + '" class="fb-options" /><div>');
|
||||
} else {
|
||||
jQuery('#fb-new-options').append('<div id="fb-option-box-' + i + '" class="fb-new-fields"><span optionid="' + i + '" class="fb-remove-option"></span><label></label><input type="text" id="fb-option' + i + '" optionid="' + i + '" value="' + FB.esc_attr( fbForm.fields[id].options[i] ) + '" class="fb-options" /><div>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Load editor & hide description
|
||||
hideDesc();
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('loadFieldEditor(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function parseShortcode (data) {
|
||||
try {
|
||||
// Clean up fields by resetting them
|
||||
fbForm.fields = {};
|
||||
// Add new fields
|
||||
if (!data) {
|
||||
fbForm.fields = defaultFields;
|
||||
} else {
|
||||
jQuery.each(data.fields, function(index, value) {
|
||||
if ( 1 === parseInt(value.required, 10) ) {
|
||||
value.required = 'true';
|
||||
}
|
||||
fbForm.fields[index] = value;
|
||||
});
|
||||
fbForm.to = data.to;
|
||||
fbForm.subject = data.subject;
|
||||
}
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('parseShortcode(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function removeOption (optionId) {
|
||||
try {
|
||||
var thisId = jQuery('#fb-field-id').val();
|
||||
var thisVal = jQuery('#fb-option' + optionId).val();
|
||||
var thisType = jQuery('#fb-new-type').val();
|
||||
// Remove from right
|
||||
jQuery('#fb-option-box-' + optionId).remove();
|
||||
// Remove from preview
|
||||
if (thisType === 'radio') {
|
||||
jQuery('#fb-radio-' + thisId + '-' + optionId).remove();
|
||||
} else if ( 'checkbox-multiple' === thisType ) {
|
||||
jQuery('#fb-checkbox-multiple-' + thisId + '-' + optionId).remove();
|
||||
} else {
|
||||
jQuery('#fb-' + thisId + '-' + optionId).remove();
|
||||
}
|
||||
// Remove from fbForm object
|
||||
var idx = fbForm.fields[thisId].options.indexOf(thisVal);
|
||||
if (idx !== -1) { fbForm.fields[thisId].options.splice(idx, 1); }
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('removeOption(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function removeOptions () {
|
||||
try {
|
||||
var thisId = jQuery('#fb-field-id').val();
|
||||
jQuery('#fb-options').hide();
|
||||
if (optionsCache[thisId] === undefined) { optionsCache[thisId] = {}; }
|
||||
optionsCache[thisId].options = fbForm.fields[thisId].options; // Save options in case they change their mind
|
||||
fbForm.fields[thisId].options = []; // Removes all options
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('removeOptions(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function sendShortcodeToEditor () {
|
||||
try {
|
||||
// Serialize fields
|
||||
jQuery('div#sortable div.fb-new-fields').each(function(index) {
|
||||
var thisId = jQuery(this).attr('fieldid');
|
||||
fbForm.fields[thisId].order = index;
|
||||
});
|
||||
// Export to WYSIWYG editor
|
||||
jQuery.post(ajaxurl, fbForm, function(response) {
|
||||
var isVisual = jQuery('#edButtonPreview', window.parent.document).hasClass('active');
|
||||
/* WP 3.3+ */
|
||||
if ( !isVisual ) {
|
||||
isVisual = jQuery( '#wp-content-wrap', window.parent.document ).hasClass( 'tmce-active' );
|
||||
}
|
||||
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
var currentCode;
|
||||
if (isVisual) {
|
||||
currentCode = win.tinyMCE.activeEditor.getContent();
|
||||
} else {
|
||||
currentCode = jQuery('#editorcontainer textarea', window.parent.document).val();
|
||||
/* WP 3.3+ */
|
||||
if ( typeof currentCode !== 'string' ) {
|
||||
currentCode = jQuery( '.wp-editor-area', window.parent.document ).val();
|
||||
}
|
||||
}
|
||||
var regexp = new RegExp('\\[contact-form\\b.*?\\/?\\](?:[\\s\\S]+?\\[\\/contact-form\\])?');
|
||||
|
||||
// Remove new lines that cause BR tags to show up
|
||||
response = response.replace(/\n/g,' ');
|
||||
// Convert characters to comma
|
||||
response = response.replace( /%26#x002c;/g , ',' );
|
||||
|
||||
// Add new shortcode
|
||||
if (currentCode.match(regexp)) {
|
||||
if (isVisual) {
|
||||
win.tinyMCE.activeEditor.execCommand('mceSetContent', false, currentCode.replace(regexp, response));
|
||||
} else {
|
||||
// looks like the visual editor is disabled,
|
||||
// update the contents of the post directly
|
||||
jQuery( '#content', window.parent.document ).val( currentCode.replace( regexp, response ) );
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
win.send_to_editor( response );
|
||||
} catch ( e ) {
|
||||
if (isVisual) {
|
||||
win.tinyMCE.activeEditor.execCommand('mceInsertContent', false, response);
|
||||
} else {
|
||||
// looks like the visual editor is disabled,
|
||||
// update the contents of the post directly
|
||||
jQuery( '#content', window.parent.document ).val( currentCode + response );
|
||||
}
|
||||
}
|
||||
}
|
||||
hidePopup();
|
||||
});
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('sendShortcodeToEditor(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function showDesc () {
|
||||
jQuery('#fb-desc').show();
|
||||
jQuery('#fb-add-field').hide();
|
||||
}
|
||||
function showAndHideMessage (message) {
|
||||
try {
|
||||
var newMessage = (!message) ? GrunionFB_i18n.savedMessage : message;
|
||||
jQuery('#fb-success').text(newMessage);
|
||||
jQuery('#fb-success').slideDown('fast');
|
||||
setTimeout(function () {
|
||||
jQuery('#fb-success').slideUp('fast');
|
||||
}, 2500);
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('showAndHideMessage(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function switchTabs (whichType) {
|
||||
try {
|
||||
if (whichType === 'preview') {
|
||||
if ( ! validateEmails( jQuery( '#fb-field-my-email' ).val() ) ) {
|
||||
return;
|
||||
}
|
||||
jQuery('#tab-preview a').addClass('current');
|
||||
jQuery('#tab-settings a').removeClass('current');
|
||||
jQuery('#fb-preview-form, #fb-desc').show();
|
||||
jQuery('#fb-email-settings, #fb-email-desc').hide();
|
||||
showAndHideMessage( GrunionFB_i18n.savedMessage );
|
||||
|
||||
} else {
|
||||
jQuery('#tab-preview a').removeClass('current');
|
||||
jQuery('#tab-settings a').addClass('current');
|
||||
jQuery('#fb-preview-form, #fb-desc, #fb-add-field').hide();
|
||||
jQuery('#fb-email-settings, #fb-email-desc').show();
|
||||
jQuery('#fb-field-my-email').focus().select();
|
||||
}
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('switchTabs(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function validateEmails( emails ) {
|
||||
// Field is allwed to be empty :)
|
||||
if ( 0 === emails.length ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var $e, emailList = emails.split( ',' );
|
||||
|
||||
for ( $e = 0 ; $e < emailList.length ; $e++ ) {
|
||||
if ( false === validateEmail( emailList[ $e ] ) ) {
|
||||
alert( emailList[ $e ] + GrunionFB_i18n.invalidEmail );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/* Uses The Official Standard: RFC 5322 -- http://www.regular-expressions.info/email.html */
|
||||
function validateEmail( email ) {
|
||||
var re = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i;
|
||||
return re.test( email );
|
||||
}
|
||||
function updateLabel () {
|
||||
try {
|
||||
var thisId = jQuery('#fb-field-id').val();
|
||||
var thisLabel = jQuery('#fb-new-label').val();
|
||||
// Update preview
|
||||
if (thisLabel.length === 0) {
|
||||
jQuery('#fb-new-field' + thisId + ' label .label-text').text( GrunionFB_i18n.newLabel );
|
||||
} else {
|
||||
jQuery('#fb-new-field' + thisId + ' label .label-text').text( thisLabel );
|
||||
}
|
||||
// Update fbForm object
|
||||
fbForm.fields[thisId].label = thisLabel;
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('updateLabel(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateMyEmail () {
|
||||
try {
|
||||
var thisEmail = jQuery('#fb-field-my-email').val();
|
||||
fbForm.to = thisEmail;
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('updateMyEmail(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateOption (that) {
|
||||
try {
|
||||
var thisId = jQuery('#fb-field-id').val();
|
||||
var thisOptionid = that.attr('optionid');
|
||||
var thisOptionValue = that.val();
|
||||
var thisType = jQuery('#fb-new-type').val();
|
||||
// Update preview
|
||||
if (thisType === 'radio') {
|
||||
jQuery('#fb-radio-' + thisId + '-' + thisOptionid + ' span').text(thisOptionValue);
|
||||
} else if ( 'checkbox-multiple' === thisType ) {
|
||||
jQuery('#fb-checkbox-multiple-' + thisId + '-' + thisOptionid + ' span').text(thisOptionValue);
|
||||
} else {
|
||||
jQuery('#fb-' + thisId + '-' + thisOptionid).text(thisOptionValue);
|
||||
}
|
||||
// Update fbForm object
|
||||
fbForm.fields[thisId].options[thisOptionid] = thisOptionValue;
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('updateOption(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateRequired () {
|
||||
try {
|
||||
var thisId = jQuery('#fb-field-id').val();
|
||||
var thisChecked = jQuery('#fb-new-required').is(':checked');
|
||||
// Update object and preview
|
||||
if (thisChecked) {
|
||||
fbForm.fields[thisId].required = true;
|
||||
jQuery('#fb-new-field' + thisId + ' label').append('<span class="label-required">' + GrunionFB_i18n.requiredLabel + '</span>');
|
||||
} else {
|
||||
fbForm.fields[thisId].required = false;
|
||||
jQuery('#fb-new-field' + thisId + ' label .label-required').remove();
|
||||
}
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('updateRequired(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateSubject () {
|
||||
try {
|
||||
var thisSubject = jQuery('#fb-field-subject').val();
|
||||
fbForm.subject = thisSubject;
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('updateSubject(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
function updateType(thisType, thisLabelText, thisRequired) {
|
||||
try {
|
||||
var thisId = jQuery('#fb-field-id').val();
|
||||
if (!thisType) { thisType = jQuery('#fb-new-type').val(); }
|
||||
if (!thisLabelText) { thisLabelText = jQuery('#fb-new-field' + thisId + ' .label-text').text(); }
|
||||
var isRequired = (thisRequired) ? '<span class="label-required">' + GrunionFB_i18n.requiredLabel + '</span>' : '';
|
||||
var thisLabel = '<label fieldid="' + thisId + '" for="fb-field' + thisId + '"><span class="label-text">' + FB.esc_html( thisLabelText ) + '</span>' + isRequired + '</label>';
|
||||
var thisRadio = '<input type="radio" name="radio-' + thisId + '" id="fb-field' + thisId + ' "disabled="disabled" />';
|
||||
var thisRadioLabel = '<label fieldid="' + thisId + '" for="fb-field' + thisId + '" class="fb-radio-label"><span class="label-text">' + FB.esc_html( thisLabelText ) + '</span>' + isRequired + '</label>';
|
||||
var thisRadioRemove = '<div class="fb-remove fb-remove-small" id="' + thisId + '"></div>';
|
||||
var thisRemove = '<div class="fb-remove" id="' + thisId + '"></div>';
|
||||
var thisCheckbox = '<input type="checkbox" id="fb-field' + thisId + '" "disabled="disabled" />';
|
||||
var thisCheckboxMultiple = '<input type="checkbox" id="fb-field' + thisId + '" "disabled="disabled" />';
|
||||
var thisCheckboxMultipleRemove = '<div class="fb-remove fb-remove-small" id="' + thisId + '"></div>';
|
||||
var thisText = '<input type="text" id="fb-field' + thisId + '" "disabled="disabled" />';
|
||||
var thisTextarea = '<textarea id="fb-field' + thisId + '" "disabled="disabled"></textarea>';
|
||||
var thisClear = '<div class="clear"></div>';
|
||||
var thisSelect = '<select id="fb-field' + thisId + '" fieldid="' + thisId + '"><option id="fb-' + thisId + '-' + optionsCount + '" value="' + thisId + '-' + optionsCount + '">' + GrunionFB_i18n.firstOptionLabel + '</option></select>';
|
||||
switch (thisType) {
|
||||
case 'checkbox':
|
||||
removeOptions();
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisRadioRemove + thisCheckbox + thisRadioLabel + thisClear);
|
||||
break;
|
||||
case 'checkbox-multiple':
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisLabel + thisCheckboxMultipleRemove + '<div fieldid="' + thisId + '" id="fb-custom-checkbox-multiple' + thisId + '"></div>');
|
||||
if (optionsCache[thisId] !== undefined && optionsCache[thisId].options.length !== 0) {
|
||||
fbForm.fields[thisId].options = optionsCache[thisId].options;
|
||||
jQuery('#fb-custom-checkbox-multiple' + thisId).append(customOptions(thisId, thisType));
|
||||
} else {
|
||||
jQuery('#fb-new-options').html('<label for="fb-option0">' + GrunionFB_i18n.optionsLabel + '</label><input type="text" id="fb-option0" optionid="0" value="' + GrunionFB_i18n.firstOptionLabel + '" class="fb-options" />');
|
||||
jQuery('#fb-custom-checkbox-multiple' + thisId).append('<div id="fb-checkbox-multiple-' + thisId + '-0">' + thisCheckboxMultiple + '<span>' + GrunionFB_i18n.firstOptionLabel + '</span>' + thisClear + '</div>');
|
||||
fbForm.fields[thisId].options[optionsCount] = GrunionFB_i18n.firstOptionLabel;
|
||||
}
|
||||
jQuery('#fb-options').show();
|
||||
setTimeout(function () { jQuery('#fb-option0').focus().select(); }, 100);
|
||||
break;
|
||||
case 'email':
|
||||
removeOptions();
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisRemove + thisLabel + thisText);
|
||||
break;
|
||||
case 'name':
|
||||
removeOptions();
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisRemove + thisLabel + thisText);
|
||||
break;
|
||||
case 'radio':
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisLabel + thisRadioRemove + '<div fieldid="' + thisId + '" id="fb-custom-radio' + thisId + '"></div>');
|
||||
if (optionsCache[thisId] !== undefined && optionsCache[thisId].options.length !== 0) {
|
||||
fbForm.fields[thisId].options = optionsCache[thisId].options;
|
||||
jQuery('#fb-custom-radio' + thisId).append(customOptions(thisId, thisType));
|
||||
} else {
|
||||
jQuery('#fb-new-options').html('<label for="fb-option0">' + GrunionFB_i18n.optionsLabel + '</label><input type="text" id="fb-option0" optionid="0" value="' + GrunionFB_i18n.firstOptionLabel + '" class="fb-options" />');
|
||||
jQuery('#fb-custom-radio' + thisId).append('<div id="fb-radio-' + thisId + '-0">' + thisRadio + '<span>' + GrunionFB_i18n.firstOptionLabel + '</span>' + thisClear + '</div>');
|
||||
fbForm.fields[thisId].options[optionsCount] = GrunionFB_i18n.firstOptionLabel;
|
||||
}
|
||||
jQuery('#fb-options').show();
|
||||
setTimeout(function () { jQuery('#fb-option0').focus().select(); }, 100);
|
||||
break;
|
||||
case 'select':
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisRemove + thisLabel + thisSelect);
|
||||
if (optionsCache[thisId] !== undefined && optionsCache[thisId].options.length !== 0) {
|
||||
fbForm.fields[thisId].options = optionsCache[thisId].options;
|
||||
jQuery('#fb-field' + thisId).html(customOptions(thisId, thisType));
|
||||
} else {
|
||||
jQuery('#fb-new-options').html('<label for="fb-option0">' + GrunionFB_i18n.optionsLabel + '</label><input type="text" id="fb-option0" optionid="0" value="' + GrunionFB_i18n.firstOptionLabel + '" class="fb-options" />');
|
||||
fbForm.fields[thisId].options[optionsCount] = GrunionFB_i18n.firstOptionLabel;
|
||||
}
|
||||
jQuery('#fb-options').show();
|
||||
setTimeout(function () { jQuery('#fb-option0').focus().select(); }, 100);
|
||||
break;
|
||||
case 'text':
|
||||
removeOptions();
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisRemove + thisLabel + thisText);
|
||||
break;
|
||||
case 'textarea':
|
||||
removeOptions();
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisRemove + thisLabel + thisTextarea);
|
||||
break;
|
||||
case 'url':
|
||||
removeOptions();
|
||||
jQuery('#fb-new-field' + thisId + ' .fb-fields').html(thisRemove + thisLabel + thisText);
|
||||
break;
|
||||
}
|
||||
// update object
|
||||
fbForm.fields[thisId].type = thisType;
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('updateType(): ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
resizePop: function () {
|
||||
try {
|
||||
//Thickbox won't resize for some reason, we are manually doing it here
|
||||
var totalWidth = jQuery('body', window.parent.document).width();
|
||||
var totalHeight = jQuery('body', window.parent.document).height();
|
||||
var isIE6 = typeof document.body.style.maxHeight === 'undefined';
|
||||
|
||||
jQuery('#TB_window, #TB_iframeContent', window.parent.document).css('width', '768px');
|
||||
jQuery('#TB_window', window.parent.document).css({ left: (totalWidth-768)/2 + 'px', top: '23px', position: 'absolute', marginLeft: '0' });
|
||||
if ( ! isIE6 ) { // take away IE6
|
||||
jQuery('#TB_window, #TB_iframeContent', window.parent.document).css('height', (totalHeight-73) + 'px');
|
||||
}
|
||||
} catch(e) {
|
||||
if (debug) {
|
||||
console.log('resizePop(): ' + e);
|
||||
}
|
||||
}
|
||||
},
|
||||
init: function () {
|
||||
// Scroll to top of page
|
||||
window.parent.scroll(0,0);
|
||||
//Check for existing form data
|
||||
var contentSource;
|
||||
if (jQuery('#edButtonPreview', window.parent.document).hasClass('active') || jQuery( '#wp-content-wrap', window.parent.document ).hasClass( 'tmce-active' ) ) {
|
||||
var win = window.dialogArguments || opener || parent || top;
|
||||
contentSource = win.tinyMCE.activeEditor.getContent();
|
||||
} else {
|
||||
contentSource = jQuery('#content', window.parent.document).val();
|
||||
}
|
||||
var data = {
|
||||
action: 'grunion_shortcode_to_json',
|
||||
'_ajax_nonce' : ajax_nonce_json,
|
||||
post_id: postId,
|
||||
content: contentSource
|
||||
};
|
||||
|
||||
var $doc = jQuery(document);
|
||||
|
||||
jQuery.post(ajaxurl, data, function(response) {
|
||||
// Setup fbForm
|
||||
parseShortcode(jQuery.parseJSON(response));
|
||||
// Now build out the preview form
|
||||
buildPreview();
|
||||
});
|
||||
// actions
|
||||
jQuery('.fb-add-field').click(function () {
|
||||
addField();
|
||||
hideDesc();
|
||||
return false;
|
||||
});
|
||||
jQuery('#fb-new-label').keyup(function () {
|
||||
updateLabel();
|
||||
});
|
||||
jQuery('#fb-new-type').change(function () {
|
||||
updateType();
|
||||
});
|
||||
jQuery('#fb-new-required').click(function () {
|
||||
updateRequired();
|
||||
});
|
||||
$doc.on('click', '.fb-remove', function () {
|
||||
showDesc();
|
||||
deleteField(jQuery(this));
|
||||
grabShortcode();
|
||||
});
|
||||
jQuery('#fb-preview').submit(function () {
|
||||
sendShortcodeToEditor();
|
||||
return false;
|
||||
});
|
||||
jQuery('#TB_overlay, #TB_closeWindowButton', window.parent.document).mousedown(function () {
|
||||
if(confirm( GrunionFB_i18n.exitConfirmMessage )) {
|
||||
hidePopup();
|
||||
}
|
||||
});
|
||||
$doc.on('click', '#fb-another-option', function () {
|
||||
addOption();
|
||||
});
|
||||
$doc.on('keyup', '.fb-options', function () {
|
||||
updateOption(jQuery(this));
|
||||
});
|
||||
$doc.on('click', '.fb-remove-option', function () {
|
||||
removeOption(jQuery(this).attr('optionid'));
|
||||
});
|
||||
jQuery('#tab-preview a').click(function () {
|
||||
switchTabs('preview');
|
||||
return false;
|
||||
});
|
||||
jQuery('#fb-prev-form').click(function () {
|
||||
switchTabs('preview');
|
||||
return false;
|
||||
});
|
||||
jQuery('#tab-settings a').click(function () {
|
||||
switchTabs();
|
||||
return false;
|
||||
});
|
||||
jQuery('#fb-field-my-email').blur(function () {
|
||||
updateMyEmail();
|
||||
});
|
||||
jQuery('#fb-field-subject').blur(function () {
|
||||
updateSubject();
|
||||
});
|
||||
$doc.on('mouseenter', '.fb-form-case .fb-new-fields', function () {
|
||||
hideShowEditLink('show', jQuery(this));
|
||||
});
|
||||
$doc.on('mouseleave', '.fb-form-case .fb-new-fields', function () {
|
||||
hideShowEditLink('hide');
|
||||
return false;
|
||||
});
|
||||
$doc.on('click', '.fb-edit-field', function () {
|
||||
editField(jQuery(this));
|
||||
return false;
|
||||
});
|
||||
$doc.on('click', '.fb-edit-field .fb-reorder', function () {
|
||||
return false;
|
||||
});
|
||||
$doc.on('click', '#fb-save-field', function () {
|
||||
showDesc();
|
||||
showAndHideMessage();
|
||||
return false;
|
||||
});
|
||||
jQuery('#fb-feedback').click(function () {
|
||||
var thisHref = jQuery(this).attr('href');
|
||||
window.parent.location = thisHref;
|
||||
return false;
|
||||
});
|
||||
jQuery('#sortable').sortable({
|
||||
axis: 'y',
|
||||
handle: '.fb-reorder',
|
||||
revert: true,
|
||||
start: function() { jQuery('.fb-edit-field').hide(); }
|
||||
});
|
||||
jQuery('#draggable').draggable({
|
||||
axis: 'y',
|
||||
handle: '.fb-reorder',
|
||||
connectToSortable: '#sortable',
|
||||
helper: 'clone',
|
||||
revert: 'invalid'
|
||||
});
|
||||
}
|
||||
};
|
||||
})();
|