$bulk_actions Modified action links.
*/
public function register_modify_bulk_actions( $bulk_actions ) {
$white_listed_actions = [
'edit',
'trash',
'delete',
'untrash',
];
// remove all actions except white listed actions.
$bulk_actions = array_intersect_key( $bulk_actions, array_flip( $white_listed_actions ) );
// Add export action only if edit and trash actions are present in bulk actions.
if ( isset( $bulk_actions['edit'] ) && isset( $bulk_actions['trash'] ) ) {
$bulk_actions['export'] = __( 'Export', 'sureforms' );
}
return $bulk_actions;
}
/**
* Show blank slate styles.
*
* @return void
* @since 0.0.1
*/
public function get_blank_state_styles() {
echo '';
}
/**
* Show blank slate.
*
* @param string $which String which tablenav is being shown.
* @return void
* @since 0.0.1
*/
public function maybe_render_blank_form_state( $which ) {
$screen = get_current_screen();
$post_type = $screen ? $screen->post_type : '';
if ( SRFM_FORMS_POST_TYPE === $post_type && 'bottom' === $which ) {
$counts = (array) wp_count_posts( SRFM_FORMS_POST_TYPE );
unset( $counts['auto-draft'] );
$count = array_sum( $counts );
if ( 0 < $count ) {
return;
}
$this->sureforms_render_blank_state( $post_type );
$this->get_blank_state_styles();
}
}
/**
* Set up a div for the header to render into it.
*
* @return void
* @since 0.0.1
*/
public static function embed_page_header() {
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
$is_screen_sureforms_entries = Helper::validate_request_context( SRFM_ENTRIES, 'page' );
if ( 'edit-' . SRFM_FORMS_POST_TYPE === $screen_id || $is_screen_sureforms_entries ) {
?>
'boolean',
'_srfm_submit_button_text' => 'string',
'_srfm_is_inline_button' => 'boolean',
// Submit Button.
'_srfm_submit_width_backend' => 'string',
'_srfm_button_border_radius' => 'integer',
'_srfm_submit_alignment' => 'string',
'_srfm_submit_alignment_backend' => 'string',
'_srfm_submit_width' => 'string',
'_srfm_inherit_theme_button' => 'boolean',
// Additional Classes.
'_srfm_additional_classes' => 'string',
// Advanced tab metas.
// Success Message.
'_srfm_submit_type' => 'string',
// Security.
'_srfm_captcha_security_type' => 'string',
'_srfm_form_recaptcha' => 'string',
]
);
// Form Custom CSS meta.
register_post_meta(
'sureforms_form',
'_srfm_form_custom_css',
[
'show_in_rest' => true,
'type' => 'string',
'single' => true,
'auth_callback' => static function() {
return current_user_can( 'edit_posts' );
},
'sanitize_callback' => static function( $meta_value ) {
return wp_kses_post( $meta_value );
},
]
);
foreach ( $metas as $meta => $type ) {
register_meta(
'post',
$meta,
[
'object_subtype' => SRFM_FORMS_POST_TYPE,
'show_in_rest' => true,
'single' => true,
'type' => $type,
'sanitize_callback' => 'sanitize_text_field',
'auth_callback' => static function() {
return current_user_can( 'edit_posts' );
},
]
);
}
// Registers meta to handle values associated with form styling.
register_post_meta(
SRFM_FORMS_POST_TYPE,
'_srfm_instant_form_settings',
[
'single' => true,
'type' => 'object',
'auth_callback' => '__return_true',
'show_in_rest' => [
'schema' => [
'type' => 'object',
'properties' => [
'site_logo' => [
'type' => 'string',
],
'site_logo_id' => [
'type' => 'integer',
],
// Form page banner settings.
'cover_type' => [
'type' => 'string',
],
'cover_color' => [
'type' => 'string',
],
'cover_image' => [
'type' => 'string',
],
'cover_image_id' => [
'type' => 'integer',
],
// Form page background settings.
'bg_type' => [
'type' => 'string',
],
'bg_color' => [
'type' => 'string',
],
'bg_image' => [
'type' => 'string',
],
'bg_image_id' => [
'type' => 'integer',
],
'enable_instant_form' => [
'type' => 'boolean',
],
'form_container_width' => [
'type' => 'integer',
],
'single_page_form_title' => [
'type' => 'boolean',
],
'use_banner_as_page_background' => [
'type' => 'boolean',
],
],
],
],
'default' => [
'bg_type' => 'color',
'bg_color' => '#ffffff',
'bg_image' => '',
'site_logo' => '',
'cover_type' => 'color',
'cover_color' => '#0C78FB',
'cover_image' => '',
'enable_instant_form' => false,
'form_container_width' => 620,
'single_page_form_title' => true,
'use_banner_as_page_background' => false,
],
]
);
register_post_meta(
SRFM_FORMS_POST_TYPE,
'_srfm_forms_styling',
[
'single' => true,
'type' => 'object',
'auth_callback' => '__return_true',
'show_in_rest' => [
'schema' => [
'type' => 'object',
'properties' => [
'primary_color' => [
'type' => 'string',
],
'text_color' => [
'type' => 'string',
],
'text_color_on_primary' => [
'type' => 'string',
],
'field_spacing' => [
'type' => 'string',
],
'submit_button_alignment' => [
'type' => 'string',
],
],
],
],
'default' => [
'primary_color' => '#0C78FB',
'text_color' => '#1E1E1E',
'text_color_on_primary' => '#FFFFFF',
'field_spacing' => 'medium',
'submit_button_alignment' => 'left',
],
]
);
// Email notification Metas.
register_post_meta(
'sureforms_form',
'_srfm_email_notification',
[
'single' => true,
'type' => 'array',
'auth_callback' => '__return_true',
'show_in_rest' => [
'schema' => [
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'id' => [
'type' => 'integer',
],
'status' => [
'type' => 'boolean',
],
'is_raw_format' => [
'type' => 'boolean',
],
'name' => [
'type' => 'string',
],
'email_to' => [
'type' => 'string',
],
'email_reply_to' => [
'type' => 'string',
],
'email_cc' => [
'type' => 'string',
],
'email_bcc' => [
'type' => 'string',
],
'subject' => [
'type' => 'string',
],
'email_body' => [
'type' => 'string',
],
],
],
],
],
'default' => [
[
'id' => 1,
'status' => true,
'is_raw_format' => false,
'name' => __( 'Admin Notification Email', 'sureforms' ),
'email_to' => '{admin_email}',
'email_reply_to' => '{admin_email}',
'email_cc' => '{admin_email}',
'email_bcc' => '{admin_email}',
'subject' => sprintf( /* translators: %s: Form title smart tag */ __( 'New Form Submission - %s', 'sureforms' ), '{form_title}' ),
'email_body' => '{all_data}',
],
],
]
);
// Compliance Settings metas.
register_post_meta(
'sureforms_form',
'_srfm_compliance',
[
'single' => true,
'type' => 'array',
'auth_callback' => '__return_true',
'show_in_rest' => [
'schema' => [
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'id' => [
'type' => 'string',
],
'gdpr' => [
'type' => 'boolean',
],
'do_not_store_entries' => [
'type' => 'boolean',
],
'auto_delete_entries' => [
'type' => 'boolean',
],
'auto_delete_days' => [
'type' => 'string',
],
],
],
],
],
'default' => [
[
'id' => 'gdpr',
'gdpr' => false,
'do_not_store_entries' => false,
'auto_delete_entries' => false,
'auto_delete_days' => '',
],
],
]
);
// form confirmation.
register_post_meta(
'sureforms_form',
'_srfm_form_confirmation',
[
'single' => true,
'type' => 'array',
'auth_callback' => '__return_true',
'show_in_rest' => [
'schema' => [
'type' => 'array',
'items' => [
'type' => 'object',
'properties' => [
'id' => [
'type' => 'integer',
],
'confirmation_type' => [
'type' => 'string',
],
'page_url' => [
'type' => 'string',
],
'custom_url' => [
'type' => 'string',
],
'message' => [
'type' => 'string',
],
'submission_action' => [
'type' => 'string',
],
'enable_query_params' => [
'type' => 'boolean',
],
'query_params' => [
'type' => 'array',
],
],
],
],
],
'default' => [
[
'id' => 1,
'confirmation_type' => 'same page',
'page_url' => '',
'custom_url' => '',
'message' => ' . ')
Thank you
We have received your email. You\'ll hear from us as soon as possible.
Please be sure to whitelist our {admin_email} email address to ensure our replies reach your inbox safely.
',
'submission_action' => 'hide form',
],
],
]
);
// conditional logic.
do_action( 'srfm_register_conditional_logic_post_meta' );
/**
* Hook for registering additional Post Meta
*/
do_action( 'srfm_register_additional_post_meta' );
}
/**
* Custom Shortcode.
*
* @param array $atts Attributes.
* @return string|false. $content Post Content.
* @since 0.0.1
*/
public function forms_shortcode( array $atts ) {
$atts = shortcode_atts(
[
'id' => '',
'show_title' => true,
],
$atts
);
$id = intval( $atts['id'] );
$post = get_post( $id );
if ( ! empty( $id ) && $post ) {
return Generate_Form_Markup::get_form_markup( $id, ! filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN ), '', 'post', true );
}
return '';
}
/**
* Add custom column header.
*
* @param array $columns Attributes.
* @return array $columns Post Content.
* @since 0.0.1
*/
public function custom_form_columns( $columns ) {
return [
'cb' => $columns['cb'],
'title' => $columns['title'],
'sureforms' => __( 'Shortcode', 'sureforms' ),
'entries' => __( 'Entries', 'sureforms' ),
'author' => $columns['author'],
'date' => $columns['date'],
];
}
/**
* Populate custom column with data.
*
* @param string $column Attributes.
* @param int $post_id Attributes.
* @return void
* @since 0.0.1
*/
public function custom_form_column_data( $column, $post_id ) {
if ( 'sureforms' === $column ) {
ob_start();
?>
$post_id,
],
admin_url( 'admin.php?page=sureforms_entries' )
),
'srfm_entries_action'
);
// Get the entry count for the form.
$entries_count = Entries::get_total_entries_by_status( 'all', $post_id );
ob_start();
?>
id : '';
if ( 'edit-sureforms_form' === $id ) {
?>
$post_types Post types.
* @since 0.0.5
* @return array $post_types Modified post types.
*/
public function unset_sureforms_post_type( $post_types ) {
return array_filter(
$post_types,
static function( $post_type ) {
if ( is_array( $post_type ) && isset( $post_type['name'] ) ) {
return SRFM_FORMS_POST_TYPE !== $post_type['name'];
}
return SRFM_FORMS_POST_TYPE !== $post_type;
}
);
}
/**
* Restrict interference of other plugins with SureForms.
*
* @since 0.0.5
* @return void
*/
private function restrict_unwanted_insertions() {
// Restrict RankMath metaboxes in edit page.
add_action( 'cmb2_admin_init', [ $this, 'restrict_data' ] );
// Restrict Yoast columns.
add_filter( 'wpseo_accessible_post_types', [ $this, 'unset_sureforms_post_type' ] );
add_filter( 'wpseo_metabox_prio', '__return_false' );
// Restrict AIOSEO columns.
add_filter( 'aioseo_public_post_types', [ $this, 'unset_sureforms_post_type' ] );
}
}