feat: manifest checks, Divi compatibility from manifests, reference fingerprints
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
function et_pb_submit_layout( $args ) {
|
||||
/**
|
||||
* Filters the layout data passed to {@see et_pb_submit_layout()}.
|
||||
*
|
||||
* @since 3.0.99
|
||||
*
|
||||
* @param string[] $args See {@see et_pb_submit_layout()} for array structure definition.
|
||||
*/
|
||||
$args = apply_filters( 'et_pb_submit_layout_args', $args );
|
||||
|
||||
if ( empty( $args ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$layout_cats_processed = array();
|
||||
$layout_tags_processed = array();
|
||||
|
||||
if ( '' !== $args['layout_selected_cats'] ) {
|
||||
$layout_cats_array = explode( ',', $args['layout_selected_cats'] );
|
||||
$layout_cats_processed = array_map( 'intval', $layout_cats_array );
|
||||
}
|
||||
|
||||
if ( '' !== $args['layout_selected_tags'] ) {
|
||||
$layout_tags_array = explode( ',', $args['layout_selected_tags'] );
|
||||
$layout_tags_processed = array_map( 'intval', $layout_tags_array );
|
||||
}
|
||||
|
||||
$meta = array();
|
||||
|
||||
if ( 'row' === $args['layout_type'] && '0' !== $args['columns_layout'] ) {
|
||||
$meta = array_merge( $meta, array( '_et_pb_row_layout' => $args['columns_layout'] ) );
|
||||
}
|
||||
|
||||
if ( 'module' === $args['layout_type'] ) {
|
||||
$meta = array_merge( $meta, array( '_et_pb_module_type' => $args['module_type'] ) );
|
||||
|
||||
// save unsynced options for global modules. Always empty for new modules.
|
||||
if ( 'global' === $args['layout_scope'] ) {
|
||||
$meta = array_merge( $meta, array( '_et_pb_excluded_global_options' => wp_json_encode( array() ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
// et_layouts_built_for_post_type.
|
||||
$meta = array_merge(
|
||||
$meta,
|
||||
array(
|
||||
'_et_pb_built_for_post_type' => $args['built_for_post_type'],
|
||||
'_et_pb_template_type' => $args['template_type'] ?? '',
|
||||
)
|
||||
);
|
||||
|
||||
$tax_input = array(
|
||||
'scope' => $args['layout_scope'],
|
||||
'layout_type' => $args['layout_type'],
|
||||
'module_width' => $args['module_width'],
|
||||
'layout_category' => $layout_cats_processed,
|
||||
'layout_tag' => $layout_tags_processed,
|
||||
'layout_location' => et_()->array_get_sanitized( $args, 'layout_location', 'local' ),
|
||||
);
|
||||
|
||||
$post_date = isset( $args['post_date'] ) && ! empty( $args['post_date'] ) ? $args['post_date'] : null;
|
||||
$new_layout_id = et_pb_create_layout( $args['layout_name'], $args['layout_content'], $meta, $tax_input, $args['layout_new_cat'], $args['layout_new_tag'], 'publish', $post_date );
|
||||
$new_post_data['post_id'] = (int) $new_layout_id;
|
||||
|
||||
$new_post_data['edit_link'] = esc_url_raw( get_edit_post_link( $new_layout_id ) );
|
||||
$json_post_data = wp_json_encode( $new_post_data );
|
||||
|
||||
return $json_post_data;
|
||||
}
|
||||
Reference in New Issue
Block a user