'layout',
'slug' => 'layout',
'domain' => 'layout_type'
);
$post['terms'][] = array(
'name' => 'not_global',
'slug' => 'not_global',
'domain' => 'scope'
);
}
$processed_posts[] = $post;
}
}
return $processed_posts;
}
add_filter( 'wp_import_posts', 'et_update_old_layouts_taxonomy', 10 );
// add custom filters for posts in the Divi Library
if ( ! function_exists( 'add_layout_filters' ) ) :
function et_pb_add_layout_filters() {
if ( isset( $_GET['post_type'] ) && 'et_pb_layout' === $_GET['post_type'] ) {
$layout_categories = get_terms( 'layout_category' );
$filter_category = array();
$filter_category[''] = __( 'All Categories', 'et_builder' );
if ( is_array( $layout_categories ) && ! empty( $layout_categories ) ) {
foreach( $layout_categories as $category ) {
$filter_category[$category->slug] = $category->name;
}
}
$filter_layout_type = array(
'' => __( 'All Layouts', 'et_builder' ),
'module' => __( 'Modules', 'et_builder' ),
'row' => __( 'Rows', 'et_builder' ),
'section' => __( 'Sections', 'et_builder' ),
'layout' => __( 'Layouts', 'et_builder' ),
);
$filter_scope = array(
'' => __( 'Global/not Global', 'et_builder' ),
'global' => __( 'Global', 'et_builder' ),
'not_global' => __( 'not Global', 'et_builder' )
);
?>
id ) {
// display wp error screen if library is disabled for current user
if ( ! et_pb_is_allowed( 'divi_library' ) || ! et_pb_is_allowed( 'add_library' ) || ! et_pb_is_allowed( 'save_library' ) ) {
wp_die( __( "you don't have sufficient permissions to access this page", 'et_builder' ) );
}
add_action( 'all_admin_notices', 'et_pb_export_layouts_interface' );
}
}
endif;
add_action( 'load-edit.php', 'et_pb_load_export_section' );
// Check whether the library editor page should be displayed or not
function et_pb_check_library_permissions(){
$current_screen = get_current_screen();
if ( 'et_pb_layout' === $current_screen->id && ( ! et_pb_is_allowed( 'divi_library' ) || ! et_pb_is_allowed( 'save_library' ) ) ) {
// display wp error screen if library is disabled for current user
wp_die( __( "you don't have sufficient permissions to access this page", 'et_builder' ) );
}
}
add_action( 'load-post.php', 'et_pb_check_library_permissions' );
// exclude premade layouts from the list of all templates in the library.
if ( ! function_exists( 'exclude_premade_layouts_library' ) ) :
function exclude_premade_layouts_library( $query ) {
global $pagenow;
$current_post_type = get_query_var( 'post_type' );
if ( is_admin() && 'edit.php' === $pagenow && $current_post_type && 'et_pb_layout' === $current_post_type ) {
$meta_query = array(
array(
'key' => '_et_pb_predefined_layout',
'value' => 'on',
'compare' => 'NOT EXISTS',
),
);
$query->set( 'meta_query', $meta_query );
}
return $query;
}
endif;
add_action( 'pre_get_posts', 'exclude_premade_layouts_library' );
if ( ! function_exists( 'et_pb_is_pagebuilder_used' ) ) :
function et_pb_is_pagebuilder_used( $page_id ) {
return ( 'on' === get_post_meta( $page_id, '_et_pb_use_builder', true ) );
}
endif;
if ( ! function_exists( 'et_pb_get_font_icon_symbols' ) ) :
function et_pb_get_font_icon_symbols() {
$symbols = array( '!', '"', '#', '$', '%', '&', ''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', );
$symbols = apply_filters( 'et_pb_font_icon_symbols', $symbols );
return $symbols;
}
endif;
if ( ! function_exists( 'et_pb_get_font_icon_list' ) ) :
function et_pb_get_font_icon_list() {
$output = is_customize_preview() ? et_pb_get_font_icon_list_items() : '<%= window.et_builder.font_icon_list_template() %>';
$output = sprintf( '
',
( $is_builder_used ? __( 'Use Default Editor', 'et_builder' ) : __( 'Use The Divi Builder', 'et_builder' ) ),
__( 'Use The Divi Builder', 'et_builder' ),
__( 'Use Default Editor', 'et_builder' ),
( $is_builder_used ? ' class="et_pb_hidden"' : '' ),
( $is_builder_used ? ' et_pb_builder_is_used' : '' ),
( $builder_always_enabled ? ' et_pb_hidden' : '' )
);
} else {
printf( '
',
( $is_builder_used ? ' class="et_pb_hidden"' : '' ),
( $is_builder_used ? ' et_pb_builder_is_used' : '' )
);
}
?>
post_type, et_builder_get_builder_post_types() ) ) return;
echo '
';
}
add_action( 'edit_form_after_editor', 'et_pb_after_main_editor' );
function et_pb_admin_scripts_styles( $hook ) {
global $typenow;
//load css file for the Divi menu
wp_enqueue_style( 'library-menu-styles', ET_BUILDER_URI . '/styles/library_menu.css', array(), ET_BUILDER_VERSION );
if ( $hook === 'widgets.php' ) {
wp_enqueue_script( 'et_pb_widgets_js', ET_BUILDER_URI . '/scripts/ext/widgets.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
wp_localize_script( 'et_pb_widgets_js', 'et_pb_options', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'et_load_nonce' => wp_create_nonce( 'et_load_nonce' ),
'widget_info' => sprintf( '
',
esc_html__( 'Here you can create new widget areas for use in the Sidebar module', 'et_builder' ),
esc_html__( 'Note: Naming your widget area "sidebar 1", "sidebar 2", "sidebar 3", "sidebar 4" or "sidebar 5" will cause conflicts with this theme', 'et_builder' ),
esc_html__( 'Widget Name', 'et_builder' ),
esc_html__( 'Create', 'et_builder' )
),
'delete_string' => esc_html__( 'Delete', 'et_builder' ),
) );
wp_enqueue_style( 'et_pb_widgets_css', ET_BUILDER_URI . '/styles/widgets.css', array(), ET_BUILDER_VERSION );
return;
}
if ( ! in_array( $hook, array( 'post-new.php', 'post.php' ) ) ) return;
/*
* Load the builder javascript and css files for custom post types
* custom post types can be added using et_builder_post_types filter
*/
$post_types = et_builder_get_builder_post_types();
if ( isset( $typenow ) && in_array( $typenow, $post_types ) ){
et_pb_add_builder_page_js_css();
}
}
add_action( 'admin_enqueue_scripts', 'et_pb_admin_scripts_styles', 10, 1 );
function et_pb_fix_builder_shortcodes( $content ) {
// if the builder is used for the page, get rid of random p tags
if ( is_singular() && 'on' === get_post_meta( get_the_ID(), '_et_pb_use_builder', true ) ) {
$content = et_pb_fix_shortcodes( $content );
}
return $content;
}
add_filter( 'the_content', 'et_pb_fix_builder_shortcodes' );
function et_pb_current_user_can_lock() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( -1 );
$permission = et_pb_is_allowed( 'lock_module' );
$permission = json_encode( $permission );
die( $permission );
}
add_action( 'wp_ajax_et_pb_current_user_can_lock', 'et_pb_current_user_can_lock' );
function et_pb_show_all_layouts() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die(-1);
printf( '
',
__( 'Replace the existing content with loaded layout', 'et_builder' ),
checked( get_theme_mod( 'et_pb_replace_content', 'on' ), 'on', false )
);
$post_type = ! empty( $_POST['et_layouts_built_for_post_type'] ) ? sanitize_text_field( $_POST['et_layouts_built_for_post_type'] ) : 'post';
$layouts_type = ! empty( $_POST['et_load_layouts_type'] ) ? sanitize_text_field( $_POST['et_load_layouts_type'] ) : 'predefined';
$predefined_operator = 'predefined' === $layouts_type ? 'EXISTS' : 'NOT EXISTS';
$query = new WP_Query( array(
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_et_pb_predefined_layout',
'value' => 'on',
'compare' => $predefined_operator,
),
),
'tax_query' => array(
array(
'taxonomy' => 'layout_type',
'field' => 'slug',
'terms' => array( 'section', 'row', 'module', 'fullwidth_section', 'specialty_section', 'fullwidth_module' ),
'operator' => 'NOT IN',
),
),
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
'posts_per_page' => '-1',
) );
if ( $query->have_posts() ) :
echo '
';
while ( $query->have_posts() ) : $query->the_post();
printf( '- %1$s%3$s%4$s
',
get_the_title(),
get_the_ID(),
esc_html__( 'Load', 'et_builder' ),
'predefined' !== $layouts_type ?
sprintf( '%1$s',
esc_html__( 'Delete', 'et_builder' )
)
: ''
);
endwhile;
echo '
';
endif;
wp_reset_postdata();
die();
}
add_action( 'wp_ajax_et_pb_show_all_layouts', 'et_pb_show_all_layouts' );
function et_pb_get_saved_templates() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die(-1);
$templates_data = array();
$layout_type = ! empty( $_POST['et_layout_type'] ) ? sanitize_text_field( $_POST['et_layout_type'] ) : 'layout';
$module_width = ! empty( $_POST['et_module_width'] ) && 'module' === $layout_type ? sanitize_text_field( $_POST['et_module_width'] ) : '';
$additional_condition = '' !== $module_width ?
array(
'taxonomy' => 'module_width',
'field' => 'slug',
'terms' => $module_width,
) : '';
$is_global = ! empty( $_POST['et_is_global'] ) ? sanitize_text_field( $_POST['et_is_global'] ) : 'false';
$global_operator = 'global' === $is_global ? 'IN' : 'NOT IN';
$specialty_condition = '';
$specialty_query = ! empty( $_POST['et_specialty_columns'] ) && 'row' === $layout_type ? sanitize_text_field( $_POST['et_specialty_columns'] ) : '0';
if ( '0' !== $specialty_query ) {
$columns_val = '3' === $specialty_query ? array( '4_4', '1_2,1_2', '1_3,1_3,1_3' ) : array( '4_4', '1_2,1_2' );
$specialty_condition = array(
array(
'key' => '_et_pb_row_layout',
'value' => $columns_val,
'compare' => 'IN',
),
);
}
$query = new WP_Query( array(
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'layout_type',
'field' => 'slug',
'terms' => $layout_type,
),
array(
'taxonomy' => 'scope',
'field' => 'slug',
'terms' => array( 'global' ),
'operator' => $global_operator,
),
$additional_condition,
),
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
'posts_per_page' => '-1',
'meta_query' => $specialty_condition,
) );
wp_reset_postdata();
if ( ! empty ( $query->posts ) ) {
foreach( $query->posts as $single_post ) {
if ( 'module' === $layout_type ) {
$module_type = get_post_meta( $single_post->ID, '_et_pb_module_type', true );
} else {
$module_type = '';
}
// add only modules allowed for current user
if ( '' === $module_type || et_pb_is_allowed( $module_type ) ) {
$categories = wp_get_post_terms( $single_post->ID, 'layout_category' );
$categories_processed = array();
if ( ! empty( $categories ) ) {
foreach( $categories as $category_data ) {
$categories_processed[] = $category_data->slug;
}
}
$templates_data[] = array(
'ID' => $single_post->ID,
'title' => $single_post->post_title,
'shortcode' => $single_post->post_content,
'is_global' => $is_global,
'layout_type' => $layout_type,
'module_type' => $module_type,
'categories' => $categories_processed,
);
}
}
}
if ( empty( $templates_data ) ) {
$templates_data = array( 'error' => __( 'You have not saved any items to your Divi Library yet. Once an item has been saved to your library, it will appear here for easy use.', 'et_builder' ) );
}
$json_templates = json_encode( $templates_data );
die( $json_templates );
}
add_action( 'wp_ajax_et_pb_get_saved_templates', 'et_pb_get_saved_templates' );
function et_pb_add_template_meta() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die(-1);
$post_id = ! empty( $_POST['et_post_id'] ) ? sanitize_text_field( $_POST['et_post_id'] ) : '';
$value = ! empty( $_POST['et_meta_value'] ) ? sanitize_text_field( $_POST['et_meta_value'] ) : '';
$custom_field = ! empty( $_POST['et_custom_field'] ) ? sanitize_text_field( $_POST['et_custom_field'] ) : '';
if ( '' !== $post_id ){
update_post_meta( $post_id, $custom_field, $value );
}
}
add_action( 'wp_ajax_et_pb_add_template_meta', 'et_pb_add_template_meta' );
function et_pb_save_layout() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( -1 );
if ( '' !== $_POST['et_layout_name'] ){
$layout_type = isset( $_POST['et_layout_type'] ) ? $_POST['et_layout_type'] : 'layout';
$layout_selected_cats = isset( $_POST['et_layout_cats'] ) ? $_POST['et_layout_cats'] : '';
$layout_new_cat = isset( $_POST['et_layout_new_cat'] ) ? $_POST['et_layout_new_cat'] : '';
$columns_layout = isset( $_POST['et_columns_layout'] ) ? $_POST['et_columns_layout'] : '0';
$module_type = isset( $_POST['et_module_type'] ) ? $_POST['et_module_type'] : 'et_pb_unknown';
$layout_cats_processed = array();
if ( '' !== $layout_selected_cats ) {
$layout_cats_array = explode( ',', $layout_selected_cats );
$layout_cats_processed = array_map( 'intval', $layout_cats_array );
}
$meta = array();
if ( 'row' === $layout_type && '0' !== $columns_layout ) {
$meta = array_merge( $meta, array( '_et_pb_row_layout' => $columns_layout ) );
}
if ( 'module' === $layout_type ) {
$meta = array_merge( $meta, array( '_et_pb_module_type' => $module_type ) );
}
$tax_input = array(
'scope' => isset( $_POST['et_layout_scope'] ) ? $_POST['et_layout_scope'] : 'not_global',
'layout_type' => $layout_type,
'module_width' => isset( $_POST['et_module_width'] ) ? $_POST['et_module_width'] : 'regular',
'layout_category' => $layout_cats_processed,
);
$new_layout_id = et_pb_create_layout( $_POST['et_layout_name'], $_POST['et_layout_content'], $meta, $tax_input, $layout_new_cat );
$new_post_data['post_id'] = $new_layout_id;
}
$new_post_data['edit_link'] = htmlspecialchars_decode( get_edit_post_link( $new_layout_id ) );
$json_post_data = json_encode( $new_post_data );
die( $json_post_data );
}
add_action( 'wp_ajax_et_pb_save_layout', 'et_pb_save_layout' );
function et_pb_get_global_module() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( -1 );
$post_id = isset( $_POST['et_global_id'] ) ? $_POST['et_global_id'] : '';
if ( '' !== $post_id ) {
$query = new WP_Query( array(
'p' => (int) $post_id,
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE
) );
wp_reset_postdata();
if ( !empty( $query->post ) ) {
$global_shortcode['shortcode'] = $query->post->post_content;
}
}
if ( empty( $global_shortcode ) ) {
$global_shortcode['error'] = 'nothing';
}
$json_post_data = json_encode( $global_shortcode );
die( $json_post_data );
}
add_action( 'wp_ajax_et_pb_get_global_module', 'et_pb_get_global_module' );
function et_pb_update_layout() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( -1 );
$post_id = isset( $_POST['et_template_post_id'] ) ? $_POST['et_template_post_id'] : '';
$new_content = isset( $_POST['et_layout_content'] ) ? $_POST['et_layout_content'] : '';
if ( '' !== $post_id ) {
$update = array(
'ID' => $post_id,
'post_content' => $new_content,
);
wp_update_post( $update );
}
die();
}
add_action( 'wp_ajax_et_pb_update_layout', 'et_pb_update_layout' );
function et_pb_load_layout() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( -1 );
$layout_id = (int) $_POST['et_layout_id'];
if ( '' === $layout_id ) die( -1 );
$replace_content = isset( $_POST['et_replace_content'] ) && 'on' === $_POST['et_replace_content'] ? 'on' : 'off';
set_theme_mod( 'et_pb_replace_content', $replace_content );
$layout = get_post( $layout_id );
if ( $layout )
echo $layout->post_content;
die();
}
add_action( 'wp_ajax_et_pb_load_layout', 'et_pb_load_layout' );
function et_pb_delete_layout() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( -1 );
$layout_id = (int) $_POST['et_layout_id'];
if ( '' === $layout_id ) die( -1 );
wp_delete_post( $layout_id );
die();
}
add_action( 'wp_ajax_et_pb_delete_layout', 'et_pb_delete_layout' );
if ( ! function_exists( 'et_pb_create_layout' ) ) :
function et_pb_create_layout( $name, $content, $meta = array(), $tax_input = array(), $new_category = '' ) {
$layout = array(
'post_title' => sanitize_text_field( $name ),
'post_content' => $content,
'post_status' => 'publish',
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE,
);
$layout_id = wp_insert_post( $layout );
if ( !empty( $meta ) ) {
foreach ( $meta as $meta_key => $meta_value ) {
add_post_meta( $layout_id, $meta_key, sanitize_text_field( $meta_value ) );
}
}
if ( '' !== $new_category ) {
$new_term_id = wp_insert_term( $new_category, 'layout_category' );
$tax_input['layout_category'][] = (int) $new_term_id['term_id'];
}
if ( ! empty( $tax_input ) ) {
foreach( $tax_input as $taxonomy => $terms ) {
wp_set_post_terms( $layout_id, $terms, $taxonomy );
}
}
return $layout_id;
}
endif;
/**
* Get layout type of given post ID
* @return string|bool
*/
if ( ! function_exists( 'et_pb_get_layout_type' ) ) :
function et_pb_get_layout_type( $post_id ) {
// Get taxonomies
$layout_type_data = wp_get_post_terms( $post_id, 'layout_type' );
if ( empty( $layout_type_data ) ) {
return false;
}
// Pluck name out of taxonomies
$layout_type_array = wp_list_pluck( $layout_type_data, 'name' );
// Logically, a layout only have one layout type.
$layout_type = implode( "|", $layout_type_array );
return $layout_type;
}
endif;
if ( ! function_exists( 'et_pb_add_builder_page_js_css' ) ) :
function et_pb_add_builder_page_js_css(){
global $typenow, $post;
// we need some post data when editing saved templates.
if ( 'et_pb_layout' === $typenow ) {
$template_scope = wp_get_object_terms( get_the_ID(), 'scope' );
$is_global_template = ! empty( $template_scope[0] ) ? $template_scope[0]->slug : 'regular';
$post_id = get_the_ID();
// Check whether it's a Global item's page and display wp error if Global items disabled for current user
if ( ! et_pb_is_allowed( 'edit_global_library' ) && 'global' === $is_global_template ) {
wp_die( __( "you don't have sufficient permissions to access this page", 'et_builder' ) );
}
} else {
$is_global_template = '';
$post_id = '';
}
// we need this data to create the filter when adding saved modules
$layout_categories = get_terms( 'layout_category' );
$layout_cat_data = array();
$layout_cat_data_json = '';
if ( is_array( $layout_categories ) && ! empty( $layout_categories ) ) {
foreach( $layout_categories as $category ) {
$layout_cat_data[] = array(
'slug' => $category->slug,
'name' => $category->name,
);
}
}
if ( ! empty( $layout_cat_data ) ) {
$layout_cat_data_json = json_encode( $layout_cat_data );
}
// Set fixed protocol for preview URL to prevent cross origin issue
$preview_scheme = is_ssl() ? 'https' : 'http';
$page_permalink = get_permalink( $post->ID );
if ( 'https' === $preview_scheme && ! strpos( $page_permalink, 'https://' ) ) {
$page_permalink = str_replace( 'http://', 'https://', $page_permalink );
}
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'underscore' );
wp_enqueue_script( 'backbone' );
wp_enqueue_script( 'google-maps-api', esc_url( add_query_arg( array( 'v' => 3, 'sensor' => 'false' ), is_ssl() ? 'https://maps-api-ssl.google.com/maps/api/js' : 'http://maps.google.com/maps/api/js' ) ), array(), '3', true );
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'wp-color-picker-alpha', ET_BUILDER_URI . '/scripts/ext/wp-color-picker-alpha.min.js', array( 'jquery', 'wp-color-picker' ), ET_BUILDER_VERSION, true );
wp_enqueue_script( 'et_pb_admin_date_js', ET_BUILDER_URI . '/scripts/ext/jquery-ui-1.10.4.custom.min.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
wp_enqueue_script( 'et_pb_admin_date_addon_js', ET_BUILDER_URI . '/scripts/ext/jquery-ui-timepicker-addon.js', array( 'et_pb_admin_date_js' ), ET_BUILDER_VERSION, true );
wp_enqueue_script( 'validation', ET_BUILDER_URI . '/scripts/ext/jquery.validate.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
wp_enqueue_script( 'minicolors', ET_BUILDER_URI . '/scripts/ext/jquery.minicolors.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
wp_enqueue_script( 'et_pb_admin_js', ET_BUILDER_URI .'/scripts/builder.js', array( 'jquery', 'jquery-ui-core', 'underscore', 'backbone' ), ET_BUILDER_VERSION, true );
wp_localize_script( 'et_pb_admin_js', 'et_pb_options', array(
'debug' => true,
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'home_url' => home_url(),
'preview_url' => add_query_arg( 'et_pb_preview', 'true', $page_permalink ),
'et_load_nonce' => wp_create_nonce( 'et_load_nonce' ),
'images_uri' => ET_BUILDER_URI .'/images',
'post_type' => $typenow,
'et_builder_module_parent_shortcodes' => ET_Builder_Element::get_parent_shortcodes( $typenow ),
'et_builder_module_child_shortcodes' => ET_Builder_Element::get_child_shortcodes( $typenow ),
'et_builder_module_raw_content_shortcodes' => ET_Builder_Element::get_raw_content_shortcodes( $typenow ),
'et_builder_modules' => ET_Builder_Element::get_modules_js_array( $typenow ),
'default_initial_column_type' => apply_filters( 'et_builder_default_initial_column_type', '4_4' ),
'default_initial_text_module' => apply_filters( 'et_builder_default_initial_text_module', 'et_pb_text' ),
'section_only_row_dragged_away' => __( 'The section should have at least one row.', 'et_builder' ),
'fullwidth_module_dragged_away' => __( 'Fullwidth module can\'t be used outside of the Fullwidth Section.', 'et_builder' ),
'stop_dropping_3_col_row' => __( '3 column row can\'t be used in this column.', 'et_builder' ),
'preview_image' => __( 'Preview', 'et_builder' ),
'empty_admin_label' => __( 'Module', 'et_builder' ),
'video_module_image_error' => __( 'Still images cannot be generated from this video service and/or this video format', 'et_builder' ),
'geocode_error' => __( 'Geocode was not successful for the following reason', 'et_builder' ),
'geocode_error_2' => __( 'Geocoder failed due to', 'et_builder' ),
'no_results' => __( 'No results found', 'et_builder' ),
'all_tab_options_hidden' => __( 'No available options for this configuration.', 'et_builder' ),
'update_global_module' => __( 'You\'re about to update global module. This change will be applied to all pages where you use this module. Press OK if you want to update this module', 'et_builder' ),
'global_row_alert' => __( 'You cannot add global rows into global sections', 'et_builder' ),
'global_module_alert' => __( 'You cannot add global modules into global sections or rows', 'et_builder' ),
'all_cat_text' => __( 'All Categories', 'et_builder' ),
'is_global_template' => $is_global_template,
'template_post_id' => $post_id,
'layout_categories' => $layout_cat_data_json,
'map_pin_address_error' => __( 'Map Pin Address cannot be empty', 'et_builder' ),
'map_pin_address_invalid' => __( 'Invalid Pin and address data. Please try again.', 'et_builder' ),
'locked_section_permission_alert' => __( 'You do not have permission to unlock this section.', 'et_builder' ),
'locked_row_permission_alert' => __( 'You do not have permission to unlock this row.', 'et_builder' ),
'locked_module_permission_alert' => __( 'You do not have permission to unlock this module.', 'et_builder' ),
'locked_item_permission_alert' => __( 'You do not have permission to perform this task.', 'et_builder' ),
'localstorage_unavailability_alert' => __( 'Unable to perform copy/paste process due to inavailability of localStorage feature in your browser. Please use latest modern browser (Chrome, Firefox, or Safari) to perform copy/paste process', 'et_builder' ),
'verb' => array(
'did' => __( 'Did', 'et_builder' ),
'added' => __( 'Added', 'et_builder' ),
'edited' => __( 'Edited', 'et_builder' ),
'removed' => __( 'Removed', 'et_builder' ),
'moved' => __( 'Moved', 'et_builder' ),
'expanded' => __( 'Expanded', 'et_builder' ),
'collapsed' => __( 'Collapsed', 'et_builder' ),
'locked' => __( 'Locked', 'et_builder' ),
'unlocked' => __( 'Unlocked', 'et_builder' ),
'cloned' => __( 'Cloned', 'et_builder' ),
'cleared' => __( 'Cleared', 'et_builder' ),
'enabled' => __( 'Enabled', 'et_builder' ),
'disabled' => __( 'Disabled', 'et_builder' ),
'copied' => __( 'Copied', 'et_builder' ),
'renamed' => __( 'Renamed', 'et_builder' ),
'loaded' => __( 'Loaded', 'et_builder' ),
),
'noun' => array(
'section' => __( 'Section', 'et_builder' ),
'saved_section' => __( 'Saved Section', 'et_builder' ),
'fullwidth_section' => __( 'Fullwidth Section', 'et_builder' ),
'specialty_section' => __( 'Specialty Section', 'et_builder' ),
'column' => __( 'Column', 'et_builder' ),
'row' => __( 'Row', 'et_builder' ),
'saved_row' => __( 'Saved Row', 'et_builder' ),
'module' => __( 'Module', 'et_builder' ),
'saved_module' => __( 'Saved Module', 'et_builder' ),
'page' => __( 'Page', 'et_builder' ),
'layout' => __( 'Layout', 'et_builder' ),
),
'invalid_color' => __( 'Invalid Color', 'et_builder' ),
'et_pb_preview_nonce' => wp_create_nonce( 'et_pb_preview_nonce' ),
'is_divi_library' => 'et_pb_layout' === $typenow ? 1 : 0,
'layout_type' => 'et_pb_layout' === $typenow ? et_pb_get_layout_type( get_the_ID() ) : 0,
) );
wp_enqueue_style( 'et_pb_admin_css', ET_BUILDER_URI .'/styles/style.css', array(), ET_BUILDER_VERSION );
wp_enqueue_style( 'et_pb_admin_date_css', ET_BUILDER_URI . '/styles/jquery-ui-1.10.4.custom.css', array(), ET_BUILDER_VERSION );
}
endif;
function et_pb_add_custom_box() {
$post_types = et_builder_get_builder_post_types();
foreach ( $post_types as $post_type ){
add_meta_box( ET_BUILDER_LAYOUT_POST_TYPE, __( 'The Divi Builder', 'et_builder' ), 'et_pb_pagebuilder_meta_box', $post_type, 'normal', 'high' );
}
}
if ( ! function_exists( 'et_pb_get_the_author_posts_link' ) ) :
function et_pb_get_the_author_posts_link(){
global $authordata, $post;
// Fallback for preview
if ( is_null( $authordata ) && isset( $post->post_author ) ) {
$authordata = get_userdata( $post->post_author );
}
// If no $author data or $post data found, don't continue
if ( is_null( $authordata ) && is_null( $post ) ) {
return;
}
$link = sprintf(
'
%3$s',
esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
esc_attr( sprintf( __( 'Posts by %s', 'et_builder' ), get_the_author() ) ),
get_the_author()
);
return apply_filters( 'the_author_posts_link', $link );
}
endif;
if ( ! function_exists( 'et_pb_get_comments_popup_link' ) ) :
function et_pb_get_comments_popup_link( $zero = false, $one = false, $more = false ){
$id = get_the_ID();
$number = get_comments_number( $id );
if ( 0 == $number && !comments_open() && !pings_open() ) return;
if ( $number > 1 )
$output = str_replace( '%', number_format_i18n( $number ), ( false === $more ) ? __( '% Comments', $themename ) : $more );
elseif ( $number == 0 )
$output = ( false === $zero ) ? __( 'No Comments', 'et_builder' ) : $zero;
else // must be one
$output = ( false === $one ) ? __( '1 Comment', 'et_builder' ) : $one;
return '';
}
endif;
if ( ! function_exists( 'et_pb_postinfo_meta' ) ) :
function et_pb_postinfo_meta( $postinfo, $date_format, $comment_zero, $comment_one, $comment_more ){
$postinfo_meta = '';
if ( in_array( 'author', $postinfo ) )
$postinfo_meta .= ' ' . esc_html__( 'by', 'et_builder' ) . ' ' . et_pb_get_the_author_posts_link();
if ( in_array( 'date', $postinfo ) ) {
if ( in_array( 'author', $postinfo ) ) $postinfo_meta .= ' | ';
$postinfo_meta .= get_the_time( wp_unslash( $date_format ) );
}
if ( in_array( 'categories', $postinfo ) ){
if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) ) $postinfo_meta .= ' | ';
$postinfo_meta .= get_the_category_list(', ');
}
if ( in_array( 'comments', $postinfo ) ){
if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) || in_array( 'categories', $postinfo ) ) $postinfo_meta .= ' | ';
$postinfo_meta .= et_pb_get_comments_popup_link( $comment_zero, $comment_one, $comment_more );
}
return $postinfo_meta;
}
endif;
if ( ! function_exists( 'et_pb_fix_shortcodes' ) ){
function et_pb_fix_shortcodes( $content, $decode_entities = false ){
if ( $decode_entities ) {
$content = et_builder_replace_code_content_entities( $content );
$content = ET_Builder_Element::convert_smart_quotes_and_amp( $content );
$content = html_entity_decode( $content, ENT_QUOTES );
}
$replace_tags_from_to = array (
'
[' => '[',
']
' => ']',
']
' => ']',
"
\n[" => '[',
);
return strtr( $content, $replace_tags_from_to );
}
}
if ( ! function_exists( 'et_pb_load_global_module' ) ) {
function et_pb_load_global_module( $global_id, $row_type = '' ) {
$global_shortcode = '';
if ( '' !== $global_id ) {
$query = new WP_Query( array(
'p' => (int) $global_id,
'post_type' => ET_BUILDER_LAYOUT_POST_TYPE
) );
wp_reset_postdata();
if ( ! empty( $query->post ) ) {
$global_shortcode = $query->post->post_content;
if ( '' !== $row_type && 'et_pb_row_inner' === $row_type ) {
$global_shortcode = str_replace( 'et_pb_row', 'et_pb_row_inner', $global_shortcode );
}
}
}
return $global_shortcode;
}
}
if ( ! function_exists( 'et_pb_extract_shortcode_content' ) ) {
function et_pb_extract_shortcode_content( $content, $shortcode_name ) {
$start = strpos( $content, ']' ) + 1;
$end = strrpos( $content, '[/' . $shortcode_name );
if ( false !== $end ) {
$content = substr( $content, $start, $end - $start );
} else {
$content = (bool) false;
}
return $content;
}
}
function et_builder_get_columns_layout() {
$layout_columns =
'<% if ( typeof et_pb_specialty !== \'undefined\' && et_pb_specialty === \'on\' ) { %>
<% } else if ( typeof view !== \'undefined\' && typeof view.model.attributes.specialty_columns !== \'undefined\' ) { %>
<% if ( view.model.attributes.specialty_columns === 3 ) { %>
<% } %>
<% } else { %>
<%
}
%>';
return apply_filters( 'et_builder_layout_columns', $layout_columns );
}
function et_pb_pagebuilder_meta_box() {
global $typenow;
do_action( 'et_pb_before_page_builder' );
echo '
';
wp_editor( '', 'et_pb_content_new', array( 'media_buttons' => true ) );
echo '
';
printf(
'
',
esc_attr( $typenow ),
! et_pb_is_allowed( 'move_module' ) ? ' et-pb-disable-sort' : ''
);
$rename_module_menu = sprintf(
'<%% if ( this.hasOption( "rename" ) ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Rename', 'et_builder' )
);
$copy_module_menu = sprintf(
'<%% if ( this.hasOption( "copy" ) ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Copy', 'et_builder' )
);
$paste_after_menu = sprintf(
'<%% if ( this.hasOption( "paste-after" ) ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Paste After', 'et_builder' )
);
$paste_menu_item = sprintf(
'<%% if ( this.hasOption( "paste-column" ) ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Paste', 'et_builder' )
);
$paste_app_menu_item = sprintf(
'<%% if ( this.hasOption( "paste-app" ) ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Paste', 'et_builder' )
);
$save_to_lib_menu = sprintf(
'<%% if ( this.hasOption( "save-to-library") ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Save to Library', 'et_builder' )
);
$lock_unlock_menu = sprintf(
'<%% if ( this.hasOption( "lock" ) ) { %%>
%1$s%2$s
<%% } %%>',
esc_html__( 'Unlock', 'et_builder' ),
esc_html__( 'Lock', 'et_builder' )
);
$enable_disable_menu = sprintf(
'<%% if ( this.hasOption( "disable" ) ) { %%>
%1$s%2$s
<%% } %%>',
esc_html__( 'Enable', 'et_builder' ),
esc_html__( 'Disable', 'et_builder' )
);
// Right click options Template
printf(
'',
et_pb_is_allowed( 'edit_module' ) && ( et_pb_is_allowed( 'general_settings' ) || et_pb_is_allowed( 'advanced_settings' ) || et_pb_is_allowed( 'custom_css_settings' ) ) ? $rename_module_menu : '',
et_pb_is_allowed( 'disable_module' ) ? $enable_disable_menu : '',
et_pb_is_allowed( 'lock_module' ) ? $lock_unlock_menu : '',
esc_html__( 'Expand', 'et_builder' ),
esc_html__( 'Collapse', 'et_builder' ), //#5
et_pb_is_allowed( 'add_module' ) ? $copy_module_menu : '',
et_pb_is_allowed( 'add_module' ) ? $paste_after_menu : '',
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'save_library' ) ? $save_to_lib_menu : '',
esc_html__( 'Undo', 'et_builder' ),
esc_html__( 'Redo', 'et_builder' ), //#10
et_pb_is_allowed( 'add_module' ) ? $paste_menu_item : '',
et_pb_is_allowed( 'add_module' ) ? $paste_app_menu_item : '',
et_pb_allowed_modules_list(),
esc_html__( 'Preview', 'et_builder' )
);
// "Rename Module Admin Label" Modal Window Template
printf(
'',
esc_html__( 'Cancel', 'et_builder' ),
esc_attr__( 'Save', 'et_builder' )
);
// "Rename Module Admin Label" Modal Content Template
printf(
'',
esc_html__( 'Rename', 'et_builder' ),
esc_html__( 'Enter a new name for this module', 'et_builder' )
);
$save_to_lib_button = sprintf(
'
%2$s
',
esc_attr__( 'Save to Library', 'et_builder' ),
esc_html__( 'Save to Library', 'et_builder' )
);
$load_from_lib_button = sprintf(
'
%2$s
',
esc_attr__( 'Load From Library', 'et_builder' ),
esc_html__( 'Load From Library', 'et_builder' )
);
$clear_layout_button = sprintf(
'
%2$s
',
esc_attr__( 'Clear Layout', 'et_builder' ),
esc_html__( 'Clear Layout', 'et_builder' )
);
// App Template
printf(
'',
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'save_library' ) ? $save_to_lib_button : '',
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'load_layout' ) && et_pb_is_allowed( 'add_library' ) && et_pb_is_allowed( 'add_module' ) ? $load_from_lib_button : '',
et_pb_is_allowed( 'add_module' ) ? $clear_layout_button : '',
esc_attr__( 'Redo', 'et_builder' ),
esc_html__( 'Redo', 'et_builder' ),
esc_attr__( 'Undo', 'et_builder' ),
esc_html__( 'Undo', 'et_builder' ),
esc_attr__( 'See History', 'et_builder' ),
esc_html__( 'See History', 'et_builder' )
);
$section_settings_button = sprintf(
'<%% if ( ( typeof et_pb_template_type === \'undefined\' || \'section\' === et_pb_template_type || \'\' === et_pb_template_type )%3$s ) { %%>
%2$s
<%% } %%>',
esc_attr__( 'Settings', 'et_builder' ),
esc_html__( 'Settings', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? ' && typeof et_pb_global_module === "undefined"' : '' // do not display settings on global sections if not allowed for current user
);
$section_clone_button = sprintf(
'
%2$s',
esc_attr__( 'Clone Section', 'et_builder' ),
esc_html__( 'Clone Section', 'et_builder' )
);
$section_remove_button = sprintf(
'
%2$s',
esc_attr__( 'Delete Section', 'et_builder' ),
esc_html__( 'Delete Section', 'et_builder' )
);
$section_unlock_button = sprintf(
'
%2$s',
esc_attr__( 'Unlock Section', 'et_builder' ),
esc_html__( 'Unlock Section', 'et_builder' )
);
// Section Template
$settings_controls = sprintf(
'
%1$s
<%% if ( typeof et_pb_template_type === \'undefined\' || ( \'section\' !== et_pb_template_type && \'row\' !== et_pb_template_type && \'module\' !== et_pb_template_type ) ) { %%>
%2$s
%3$s
<%% } %%>
%5$s
%6$s
',
et_pb_is_allowed( 'edit_module' ) && ( et_pb_is_allowed( 'general_settings' ) || et_pb_is_allowed( 'advanced_settings' ) || et_pb_is_allowed( 'custom_css_settings' ) ) ? $section_settings_button : '',
et_pb_is_allowed( 'add_module' ) ? $section_clone_button : '',
et_pb_is_allowed( 'add_module' ) ? $section_remove_button : '',
esc_attr__( 'Expand Section', 'et_builder' ),
esc_html__( 'Expand Section', 'et_builder' ),
et_pb_is_allowed( 'lock_module' ) ? $section_unlock_button : ''
);
$add_from_lib_section = sprintf(
'
%1$s',
esc_html__( 'Add From Library', 'et_builder' )
);
$settings_add_controls = sprintf(
'<%% if ( typeof et_pb_template_type === \'undefined\' || ( \'section\' !== et_pb_template_type && \'row\' !== et_pb_template_type && \'module\' !== et_pb_template_type ) ) { %%>
%1$s
%2$s
%3$s
%4$s
<%% } %%>',
esc_html__( 'Standard Section', 'et_builder' ),
esc_html__( 'Fullwidth Section', 'et_builder' ),
esc_html__( 'Specialty Section', 'et_builder' ),
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'add_library' ) ? $add_from_lib_section : ''
);
printf(
'',
apply_filters( 'et_builder_section_settings_controls', $settings_controls ),
et_pb_is_allowed( 'add_module' ) ? apply_filters( 'et_builder_section_add_controls', $settings_add_controls ) : '',
! et_pb_is_allowed( 'move_module' ) ? ' et-pb-disable-sort' : '',
! et_pb_is_allowed( 'edit_global_library' )
? sprintf( '<%%= typeof et_pb_global_module !== \'undefined\' ? \' et-pb-disable-sort\' : \'\' %%>' )
: ''
);
$row_settings_button = sprintf(
'<%% if ( ( typeof et_pb_template_type === \'undefined\' || et_pb_template_type !== \'module\' )%3$s ) { %%>
%2$s
<%% } %%>',
esc_attr__( 'Settings', 'et_builder' ),
esc_html__( 'Settings', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? ' && ( typeof et_pb_global_module === "undefined" || "" === et_pb_global_module ) && ( typeof et_pb_global_parent === "undefined" || "" === et_pb_global_parent )' : '' // do not display settings button on global rows if not allowed for current user
);
$row_clone_button = sprintf(
'%3$s
%2$s
%4$s',
esc_attr__( 'Clone Row', 'et_builder' ),
esc_html__( 'Clone Row', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? '<% if ( typeof et_pb_global_parent === "undefined" || "" === et_pb_global_parent ) { %>' : '', // do not display clone button on rows within global sections if not allowed for current user
! et_pb_is_allowed( 'edit_global_library' ) ? '<% } %>' : ''
);
$row_remove_button = sprintf(
'%3$s
%2$s
%4$s',
esc_attr__( 'Delete Row', 'et_builder' ),
esc_html__( 'Delete Row', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? '<% if ( typeof et_pb_global_parent === "undefined" || "" === et_pb_global_parent ) { %>' : '', // do not display clone button on rows within global sections if not allowed for current user
! et_pb_is_allowed( 'edit_global_library' ) ? '<% } %>' : ''
);
$row_change_structure_button = sprintf(
'%3$s
%2$s
%4$s',
esc_attr__( 'Change Structure', 'et_builder' ),
esc_html__( 'Change Structure', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? '<% if ( ( typeof et_pb_global_module === "undefined" || "" === et_pb_global_module ) && ( typeof et_pb_global_parent === "undefined" || "" === et_pb_global_parent ) ) { %>' : '', // do not display change structure button on global rows if not allowed for current user
! et_pb_is_allowed( 'edit_global_library' ) ? '<% } %>' : ''
);
$row_unlock_button = sprintf(
'
%2$s',
esc_attr__( 'Unlock Row', 'et_builder' ),
esc_html__( 'Unlock Row', 'et_builder' )
);
// Row Template
$settings = sprintf(
'
%1$s
<%% if ( typeof et_pb_template_type === \'undefined\' || \'section\' === et_pb_template_type ) { %%>
%2$s
<%% }
if ( typeof et_pb_template_type === \'undefined\' || et_pb_template_type !== \'module\' ) { %%>
%4$s
<%% }
if ( typeof et_pb_template_type === \'undefined\' || \'section\' === et_pb_template_type ) { %%>
%3$s
<%% } %%>
%6$s
%7$s
',
et_pb_is_allowed( 'edit_module' ) && ( et_pb_is_allowed( 'general_settings' ) || et_pb_is_allowed( 'advanced_settings' ) || et_pb_is_allowed( 'custom_css_settings' ) ) ? $row_settings_button : '',
et_pb_is_allowed( 'add_module' ) ? $row_clone_button : '',
et_pb_is_allowed( 'add_module' ) ? $row_remove_button : '',
et_pb_is_allowed( 'edit_module' ) && ( et_pb_is_allowed( 'general_settings' ) || et_pb_is_allowed( 'advanced_settings' ) || et_pb_is_allowed( 'custom_css_settings' ) ) ? $row_change_structure_button : '',
esc_attr__( 'Expand Row', 'et_builder' ),
esc_html__( 'Expand Row', 'et_builder' ),
et_pb_is_allowed( 'lock_module' ) ? $row_unlock_button : ''
);
$row_class = sprintf(
'class="et-pb-row-content et-pb-data-cid%1$s%2$s <%%= typeof et_pb_template_type !== \'undefined\' && \'module\' === et_pb_template_type ? \' et_pb_hide_insert\' : \'\' %%>"',
! et_pb_is_allowed( 'move_module' ) ? ' et-pb-disable-sort' : '',
! et_pb_is_allowed( 'edit_global_library' )
? sprintf( '<%%= typeof et_pb_global_parent !== \'undefined\' || typeof et_pb_global_module !== \'undefined\' ? \' et-pb-disable-sort\' : \'\' %%>' )
: ''
);
$data_skip = 'data-skip="<%= typeof( et_pb_skip_module ) === \'undefined\' ? \'false\' : \'true\' %>"';
$add_row_button = sprintf(
'<%% if ( ( typeof et_pb_template_type === \'undefined\' || \'section\' === et_pb_template_type )%2$s ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Add Row', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? ' && typeof et_pb_global_parent === "undefined"' : '' // do not display add row buton on global sections if not allowed for current user
);
$insert_column_button = sprintf(
'
%1$s
',
esc_html__( 'Insert Column(s)', 'et_builder' )
);
printf(
'',
apply_filters( 'et_builder_row_settings_controls', $settings ),
$row_class,
$data_skip,
et_pb_is_allowed( 'add_module' ) ? $insert_column_button : '',
et_pb_is_allowed( 'add_module' ) ? $add_row_button : ''
);
// Module Block Template
$clone_button = sprintf(
'<%% if ( ( typeof et_pb_template_type === \'undefined\' || et_pb_template_type !== \'module\' )%3$s && _.contains(%4$s, module_type) ) { %%>
%2$s
<%% } %%>',
esc_attr__( 'Clone Module', 'et_builder' ),
esc_html__( 'Clone Module', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? ' && ( typeof et_pb_global_parent === "undefined" || "" === et_pb_global_parent )' : '',
et_pb_allowed_modules_list()
);
$remove_button = sprintf(
'<%% if ( ( typeof et_pb_template_type === \'undefined\' || et_pb_template_type !== \'module\' )%3$s && _.contains(%4$s, module_type) ) { %%>
%2$s
<%% } %%>',
esc_attr__( 'Remove Module', 'et_builder' ),
esc_html__( 'Remove Module', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? ' && ( typeof et_pb_global_parent === "undefined" || "" === et_pb_global_parent )' : '',
et_pb_allowed_modules_list()
);
$unlock_button = sprintf(
'<%% if ( typeof et_pb_template_type === \'undefined\' || et_pb_template_type !== \'module\' ) { %%>
%2$s
<%% } %%>',
esc_html__( 'Unlock Module', 'et_builder' ),
esc_attr__( 'Unlock Module', 'et_builder' )
);
$settings_button = sprintf(
'<%% if (%3$s _.contains( %4$s, module_type ) ) { %%>
%2$s
<%% } %%>',
esc_attr__( 'Module Settings', 'et_builder' ),
esc_html__( 'Module Settings', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? ' ( typeof et_pb_global_parent === "undefined" || "" === et_pb_global_parent ) && ( typeof et_pb_global_module === "undefined" || "" === et_pb_global_module ) &&' : '',
et_pb_allowed_modules_list()
);
printf(
'',
et_pb_is_allowed( 'edit_module' ) && ( et_pb_is_allowed( 'general_settings' ) || et_pb_is_allowed( 'advanced_settings' ) || et_pb_is_allowed( 'custom_css_settings' ) ) ? $settings_button : '',
et_pb_is_allowed( 'add_module' ) ? $clone_button : '',
et_pb_is_allowed( 'add_module' ) ? $remove_button : '',
et_pb_is_allowed( 'lock_module' ) ? $unlock_button : ''
);
// Modal Template
$save_exit_button = sprintf(
'
%1$s
',
esc_html__( 'Save & Exit', 'et_builder' )
);
$save_template_button = sprintf(
'<%% if ( typeof et_pb_template_type === \'undefined\' || \'\' === et_pb_template_type ) { %%>
%1$s
<%% } %%>',
esc_html__( 'Save & Add To Library', 'et_builder' )
);
$preview_template_button = sprintf(
'
%1$s
',
esc_html__( 'Preview', 'et_builder' )
);
$can_edit_or_has_modal_view_tab = et_pb_is_allowed( 'edit_module' ) && ( et_pb_is_allowed( 'general_settings' ) || et_pb_is_allowed( 'advanced_settings' ) || et_pb_is_allowed( 'custom_css_settings' ) );
printf(
'',
esc_html__( 'Cancel', 'et_builder' ),
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'save_library' ) ? $save_template_button : '',
$can_edit_or_has_modal_view_tab ? $save_exit_button : '',
! et_pb_is_allowed( 'divi_library' ) || ! et_pb_is_allowed( 'save_library' ) ? ' et_pb_single_button' : '',
$preview_template_button,
$can_edit_or_has_modal_view_tab ? '' : ' et_pb_no_editing'
);
// Column Settings Template
$columns_number =
'<% if ( view.model.attributes.specialty_columns === 3 ) { %>
3
<% } else { %>
2
<% } %>';
$data_specialty_columns = sprintf(
'<%% if ( typeof view !== \'undefined\' && typeof view.model.attributes.specialty_columns !== \'undefined\' ) { %%>
data-specialty_columns="%1$s"
<%% } %%>',
$columns_number
);
$saved_row_tab = sprintf(
'
%1$s
',
esc_html__( 'Add From Library', 'et_builder' )
);
$saved_row_container = '<% if ( ( typeof change_structure === \'undefined\' || \'true\' !== change_structure ) && ( typeof et_pb_specialty === \'undefined\' || et_pb_specialty !== \'on\' ) ) { %>
<% } %>';
printf(
'',
esc_html__( 'Insert Columns', 'et_builder' ),
$data_specialty_columns,
esc_html__( 'New Row', 'et_builder' ),
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'add_library' ) ? $saved_row_tab : '',
et_builder_get_columns_layout(),
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'add_library' ) ? $saved_row_container : ''
);
// "Add Module" Template
$fullwidth_class =
'<% if ( typeof module.fullwidth_only !== \'undefined\' && module.fullwidth_only === \'on\' ) { %> et_pb_fullwidth_only_module<% } %>';
$saved_modules_tab = sprintf(
'
%1$s
',
esc_html__( 'Add From Library', 'et_builder' )
);
$saved_modules_container = '
';
printf(
'',
esc_html__( 'Insert Module', 'et_builder' ),
esc_html__( 'New Module', 'et_builder' ),
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'add_library' ) ? $saved_modules_tab : '',
$fullwidth_class,
et_pb_is_allowed( 'divi_library' ) && et_pb_is_allowed( 'add_library' ) ? $saved_modules_container : '',
et_pb_allowed_modules_list()
);
// Load Layout Template
printf(
'',
esc_html__( 'Load Layout', 'et_builder' ),
esc_html__( 'Predefined Layouts', 'et_builder' ),
esc_html__( 'Add From Library', 'et_builder' )
);
$insert_module_button = sprintf(
'%2$s
%1$s
%3$s',
esc_html__( 'Insert Module(s)', 'et_builder' ),
! et_pb_is_allowed( 'edit_global_library' ) ? '<% if ( typeof et_pb_global_parent === "undefined" ) { %>' : '',
! et_pb_is_allowed( 'edit_global_library' ) ? '<% } %>' : ''
);
// Column Template
printf(
'',
et_pb_is_allowed( 'add_module' ) ? $insert_module_button : ''
);
// Advanced Settings Buttons Module
printf(
'',
esc_html__( 'Delete', 'et_builder' ),
esc_html__( 'Settings', 'et_builder' ),
esc_html__( 'Clone Module', 'et_builder' )
);
// Advanced Settings Modal Buttons Template
printf(
'',
esc_html__( 'Cancel', 'et_builder' ),
esc_html__( 'Save', 'et_builder' )
);
// "Deactivate Builder" Modal Message Template
printf(
'',
esc_html__( 'Disable Builder', 'et_builder' ),
esc_html__( 'All content created in the Divi Builder will be lost. Previous content will be restored.', 'et_builder' ),
esc_html__( 'Do you wish to proceed?', 'et_builder' )
);
// "Clear Layout" Modal Window Template
printf(
'',
esc_html__( 'Clear Layout', 'et_builder' ),
esc_html__( 'All of your current page content will be lost.', 'et_builder' ),
esc_html__( 'Do you wish to proceed?', 'et_builder' )
);
// "Reset Advanced Settings" Modal Template
printf(
'',
esc_html__( 'All advanced module settings in will be lost.', 'et_builder' ),
esc_html__( 'Do you wish to proceed?', 'et_builder' )
);
// "Save Layout" Modal Window Template
printf(
'',
esc_html__( 'Cancel', 'et_builder' ),
esc_html__( 'Save', 'et_builder' )
);
// "Save Layout" Modal Content Template
printf(
'',
esc_html__( 'Save To Library', 'et_builder' ),
esc_html__( 'Save your current page to the Divi Library for later use.', 'et_builder' ),
esc_html__( 'Layout Name:', 'et_builder' )
);
// "Save Template" Modal Window Layout
printf(
'',
esc_attr__( 'Save And Add To Library', 'et_builder' )
);
// "Save Template" Content Layout
$layout_categories = get_terms( 'layout_category', array( 'hide_empty' => false ) );
$categories_output = sprintf( '
';
}
$categories_output .= sprintf( '
',
esc_html__( 'Create New Category', 'et_builder' )
);
$general_checkbox = sprintf(
'
',
esc_html__( 'Include General settings', 'et_builder' )
);
$advanced_checkbox = sprintf(
'
',
esc_html__( 'Include Advanced Design settings', 'et_builder' )
);
$css_checkbox = sprintf(
'
',
esc_html__( 'Include Custom CSS', 'et_builder' )
);
printf(
'',
esc_html__( 'Here you can save the current item and add it to your Divi Library for later use as well.', 'et_builder' ),
esc_html__( 'Template Name', 'et_builder' ),
esc_html__( 'Selective Sync', 'et_builder' ),
et_pb_is_allowed( 'general_settings' ) ? $general_checkbox : '',
et_pb_is_allowed( 'advanced_settings' ) ? $advanced_checkbox : '',
et_pb_is_allowed( 'custom_css_settings' ) ? $css_checkbox : '',
esc_html__( 'Please select at least 1 tab to save', 'et_builder' ),
esc_html__( 'Save as Global:', 'et_builder' ),
esc_html__( 'Make this a global item', 'et_builder' ),
$categories_output
);
// Prompt Modal Window Template
printf(
'',
esc_html__( 'No', 'et_builder' ),
esc_html__( 'Yes', 'et_builder' )
);
// "Add Specialty Section" Button Template
printf(
'',
esc_html__( 'Add Specialty Section', 'et_builder' )
);
// Saved Entry Template
echo
'';
// Font Icons Template
printf(
'',
et_builder_get_font_options_items()
);
// Font Icons Template
printf(
'',
et_pb_get_font_icon_list_items()
);
// Histories Visualizer Item Template
printf(
''
);
// Font Down Icons Template
printf(
'',
et_pb_get_font_down_icon_list_items()
);
do_action( 'et_pb_after_page_builder' );
}
/**
* Get post format with filterable output
*
* @todo once WordPress provide filter for get_post_format() output, this function can be retired
* @see get_post_format()
*
* @return mixed string|bool string of post format or false for default
*/
function et_pb_post_format() {
return apply_filters( 'et_pb_post_format', get_post_format(), get_the_ID() );
}
/**
* Return post format into false when using pagebuilder
*
* @return mixed string|bool string of post format or false for default
*/
function et_pb_post_format_in_pagebuilder( $post_format, $post_id ) {
if ( et_pb_is_pagebuilder_used( $post_id ) ) {
return false;
}
return $post_format;
}
add_filter( 'et_pb_post_format', 'et_pb_post_format_in_pagebuilder', 10, 2 );
/*
* Is Builder plugin active?
*
* @return bool True - if the plugin is active
*/
if ( ! function_exists( 'et_is_builder_plugin_active' ) ) :
function et_is_builder_plugin_active() {
return (bool) defined( 'ET_BUILDER_PLUGIN_ACTIVE' );
}
endif;
if ( ! function_exists( 'et_pb_get_mailchimp_lists' ) ) :
function et_pb_get_mailchimp_lists() {
$lists = array();
$mailchimp_api_key = et_get_option( 'divi_mailchimp_api_key' );
if ( empty( $mailchimp_api_key ) ) {
return false;
}
if ( 'on' === et_get_option( 'divi_regenerate_mailchimp_lists', 'false' ) || false === ( $et_pb_mailchimp_lists = get_transient( 'et_pb_mailchimp_lists' ) ) ) {
if ( ! class_exists( 'MailChimp_Divi' ) ) {
require_once( ET_BUILDER_DIR . 'subscription/mailchimp/mailchimp.php' );
}
try {
$mailchimp = new MailChimp_Divi( $mailchimp_api_key );
$retval = $mailchimp->call('lists/list');
if ( ! empty( $retval['data'] ) ) {
foreach ( $retval['data'] as $list ) {
$lists[$list['id']] = $list['name'];
}
}
set_transient( 'et_pb_mailchimp_lists', $lists, 60*60*24 );
} catch ( Exception $exc ) {
$lists = $et_pb_mailchimp_lists;
}
return $lists;
}
}
endif;
if ( ! function_exists( 'et_pb_get_aweber_account' ) ) :
function et_pb_get_aweber_account() {
if ( ! class_exists( 'AWeberAPI' ) ) {
require_once( ET_BUILDER_DIR . 'subscription/aweber/aweber_api.php' );
}
$consumer_key = et_get_option( 'divi_aweber_consumer_key' );
$consumer_secret = et_get_option( 'divi_aweber_consumer_secret' );
$access_key = et_get_option( 'divi_aweber_access_key' );
$access_secret = et_get_option( 'divi_aweber_access_secret' );
if ( ! empty( $consumer_key ) && ! empty( $consumer_secret ) && ! empty( $access_key ) && ! empty( $access_secret ) ) {
try {
// Aweber requires curl extension to be enabled
if ( ! function_exists( 'curl_init' ) ) {
return false;
}
$aweber = new AWeberAPI( $consumer_key, $consumer_secret );
if ( ! $aweber ) {
return false;
}
$account = $aweber->getAccount( $access_key, $access_secret );
} catch ( Exception $exc ) {
return false;
}
} else {
return false;
}
return $account;
}
endif;
if ( ! function_exists( 'et_pb_get_aweber_lists' ) ) :
function et_pb_get_aweber_lists() {
$lists = array();
$account = et_pb_get_aweber_account();
if ( ! $account ) {
return false;
}
if ( 'on' === et_get_option( 'divi_regenerate_aweber_lists', 'false' ) || false === ( $et_pb_aweber_lists = get_transient( 'et_pb_aweber_lists' ) ) ) {
if ( ! class_exists( 'AWeberAPI' ) ) {
require_once( ET_BUILDER_DIR . 'subscription/aweber/aweber_api.php' );
}
$aweber_lists = $account->lists;
if ( isset( $aweber_lists ) ) {
foreach ( $aweber_lists as $list ) {
$lists[$list->id] = $list->name;
}
}
set_transient( 'et_pb_aweber_lists', $lists, 60*60*24 );
} else {
$lists = $et_pb_aweber_lists;
}
return $lists;
}
endif;
function et_pb_submit_subscribe_form() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( json_encode( array( 'error' => __( 'Configuration error', 'Divi' ) ) ) );
$service = sanitize_text_field( $_POST['et_service'] );
$list_id = sanitize_text_field( $_POST['et_list_id'] );
$email = sanitize_email( $_POST['et_email'] );
$firstname = sanitize_text_field( $_POST['et_firstname'] );
if ( '' === $firstname ) die( json_encode( array( 'error' => __( 'Please enter first name', 'Divi' ) ) ) );
if ( ! is_email( sanitize_email( $_POST['et_email'] ) ) ) die( json_encode( array( 'error' => __( 'Incorrect email', 'Divi' ) ) ) );
if ( '' == $list_id ) die( json_encode( array( 'error' => __( 'Configuration error: List is not defined', 'Divi' ) ) ) );
$success_message = __( '
Subscribed - look for the confirmation email!
', 'Divi' );
switch ( $service ) {
case 'mailchimp' :
$lastname = sanitize_text_field( $_POST['et_lastname'] );
$email = array( 'email' => $email );
if ( ! class_exists( 'MailChimp_Divi' ) )
require_once( ET_BUILDER_DIR . 'subscription/mailchimp/mailchimp.php' );
$mailchimp_api_key = et_get_option( 'divi_mailchimp_api_key' );
if ( '' === $mailchimp_api_key ) die( json_encode( array( 'error' => __( 'Configuration error: api key is not defined', 'Divi' ) ) ) );
$mailchimp = new MailChimp_Divi( $mailchimp_api_key );
$merge_vars = array(
'FNAME' => $firstname,
'LNAME' => $lastname,
);
$retval = $mailchimp->call('lists/subscribe', array(
'id' => $list_id,
'email' => $email,
'merge_vars' => $merge_vars,
));
if ( isset($retval['error']) ) {
if ( '214' == $retval['code'] ) {
$error_message = str_replace( 'Click here to update your profile.', '', $retval['error'] );
$result = json_encode( array( 'success' => $error_message ) );
} else {
$result = json_encode( array( 'success' => $retval['error'] ) );
}
} else {
$result = json_encode( array( 'success' => $success_message ) );
}
die( $result );
break;
case 'aweber' :
if ( ! class_exists( 'AWeberAPI' ) ) {
require_once( ET_BUILDER_DIR . 'subscription/aweber/aweber_api.php' );
}
$account = et_pb_get_aweber_account();
if ( ! $account ) {
die( json_encode( array( 'error' => __( 'Aweber: Wrong configuration data', 'Divi' ) ) ) );
}
try {
$list_url = "/accounts/{$account->id}/lists/{$list_id}";
$list = $account->loadFromUrl( $list_url );
$new_subscriber = $list->subscribers->create(
array(
'email' => $email,
'name' => $firstname,
)
);
die( json_encode( array( 'success' => $success_message ) ) );
} catch ( Exception $exc ) {
die( json_encode( array( 'error' => $exc->message ) ) );
}
break;
}
die();
}
add_action( 'wp_ajax_et_pb_submit_subscribe_form', 'et_pb_submit_subscribe_form' );
add_action( 'wp_ajax_nopriv_et_pb_submit_subscribe_form', 'et_pb_submit_subscribe_form' );
function et_aweber_authorization_option() {
wp_enqueue_script( 'divi-advanced-options', get_template_directory_uri() . '/js/advanced_options.js', array( 'jquery' ), ET_BUILDER_VERSION, true );
wp_localize_script( 'divi-advanced-options', 'et_advanced_options', array(
'et_load_nonce' => wp_create_nonce( 'et_load_nonce' ),
'aweber_connecting' => __( 'Connecting...', 'Divi' ),
'aweber_failed' => __( 'Connection failed', 'Divi' ),
'aweber_remove_connection' => __( 'Removing connection...', 'Divi' ),
'aweber_done' => __( 'Done', 'Divi' ),
) );
wp_enqueue_style( 'divi-advanced-options', get_template_directory_uri() . '/css/advanced_options.css', array(), ET_BUILDER_VERSION );
$app_id = 'b17f3351';
$aweber_auth_endpoint = 'https://auth.aweber.com/1.0/oauth/authorize_app/' . $app_id;
$hide_style = ' style="display: none;"';
$aweber_connection_established = et_get_option( 'divi_aweber_consumer_key', false ) && et_get_option( 'divi_aweber_consumer_secret', false ) && et_get_option( 'divi_aweber_access_key', false ) && et_get_option( 'divi_aweber_access_secret', false );
$output = sprintf(
'
',
sprintf( __( 'Step 1:
Generate authorization code', 'Divi' ), esc_url( $aweber_auth_endpoint ) ),
__( 'Step 2: Paste in the authorization code and click "Make a connection" button: ', 'Divi' ),
__( 'Make a connection', 'Divi' ),
( $aweber_connection_established ? $hide_style : '' ),
( ! $aweber_connection_established ? $hide_style : '' ),
__( 'Aweber is set up properly. You can remove connection here if you wish.', 'Divi' ),
__( 'Remove the connection', 'Divi' )
);
echo $output;
}
function et_aweber_submit_authorization_code() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) {
die( __( 'Nonce failed.', 'Divi' ) );
}
$et_authorization_code = $_POST['et_authorization_code'];
if ( '' === $et_authorization_code ) {
die( __( 'Authorization code is empty.', 'Divi' ) );
}
if ( ! class_exists( 'AWeberAPI' ) ) {
require_once( ET_BUILDER_DIR . 'subscription/aweber/aweber_api.php' );
}
try {
$auth = AWeberAPI::getDataFromAweberID( $et_authorization_code );
if ( ! ( is_array( $auth ) && 4 === count( $auth ) ) ) {
die ( __( 'Authorization code is invalid. Try regenerating it and paste in the new code.', 'Divi' ) );
}
list( $consumer_key, $consumer_secret, $access_key, $access_secret ) = $auth;
et_update_option( 'divi_aweber_consumer_key', $consumer_key );
et_update_option( 'divi_aweber_consumer_secret', $consumer_secret );
et_update_option( 'divi_aweber_access_key', $access_key );
et_update_option( 'divi_aweber_access_secret', $access_secret );
die( 'success' );
} catch ( AWeberAPIException $exc ) {
printf(
'
%4$s.
- %5$s: %1$s
- %6$s: %2$s
- %7$s: %3$s
',
esc_html( $exc->type ),
esc_html( $exc->message ),
esc_html( $exc->documentation_url ),
esc_html__( 'Aweber API Exception', 'Divi' ),
esc_html__( 'Type', 'Divi' ),
esc_html__( 'Message', 'Divi' ),
esc_html__( 'Documentation', 'Divi' )
);
}
die();
}
add_action( 'wp_ajax_et_aweber_submit_authorization_code', 'et_aweber_submit_authorization_code' );
function et_aweber_remove_connection() {
if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) {
die( __( 'Nonce failed', 'Divi' ) );
}
et_delete_option( 'divi_aweber_consumer_key' );
et_delete_option( 'divi_aweber_consumer_secret' );
et_delete_option( 'divi_aweber_access_key' );
et_delete_option( 'divi_aweber_access_secret' );
die( 'success' );
}
add_action( 'wp_ajax_et_aweber_remove_connection', 'et_aweber_remove_connection' );
// @todo: replace 'Divi' domain with 'et_builder' in all framework files
if ( ! function_exists( 'et_pb_register_posttypes' ) ) :
function et_pb_register_posttypes() {
$labels = array(
'name' => __( 'Projects', 'Divi' ),
'singular_name' => __( 'Project', 'Divi' ),
'add_new' => __( 'Add New', 'Divi' ),
'add_new_item' => __( 'Add New Project', 'Divi' ),
'edit_item' => __( 'Edit Project', 'Divi' ),
'new_item' => __( 'New Project', 'Divi' ),
'all_items' => __( 'All Projects', 'Divi' ),
'view_item' => __( 'View Project', 'Divi' ),
'search_items' => __( 'Search Projects', 'Divi' ),
'not_found' => __( 'Nothing found', 'Divi' ),
'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
'parent_item_colon' => '',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'can_export' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'has_archive' => true,
'rewrite' => apply_filters( 'et_project_posttype_rewrite_args', array(
'feeds' => true,
'slug' => 'project',
'with_front' => false,
) ),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'author', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
);
register_post_type( 'project', apply_filters( 'et_project_posttype_args', $args ) );
$labels = array(
'name' => __( 'Project Categories', 'Divi' ),
'singular_name' => __( 'Project Category', 'Divi' ),
'search_items' => __( 'Search Categories', 'Divi' ),
'all_items' => __( 'All Categories', 'Divi' ),
'parent_item' => __( 'Parent Category', 'Divi' ),
'parent_item_colon' => __( 'Parent Category:', 'Divi' ),
'edit_item' => __( 'Edit Category', 'Divi' ),
'update_item' => __( 'Update Category', 'Divi' ),
'add_new_item' => __( 'Add New Category', 'Divi' ),
'new_item_name' => __( 'New Category Name', 'Divi' ),
'menu_name' => __( 'Categories', 'Divi' ),
);
register_taxonomy( 'project_category', array( 'project' ), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
) );
$labels = array(
'name' => __( 'Project Tags', 'Divi' ),
'singular_name' => __( 'Project Tag', 'Divi' ),
'search_items' => __( 'Search Tags', 'Divi' ),
'all_items' => __( 'All Tags', 'Divi' ),
'parent_item' => __( 'Parent Tag', 'Divi' ),
'parent_item_colon' => __( 'Parent Tag:', 'Divi' ),
'edit_item' => __( 'Edit Tag', 'Divi' ),
'update_item' => __( 'Update Tag', 'Divi' ),
'add_new_item' => __( 'Add New Tag', 'Divi' ),
'new_item_name' => __( 'New Tag Name', 'Divi' ),
'menu_name' => __( 'Tags', 'Divi' ),
);
register_taxonomy( 'project_tag', array( 'project' ), array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
) );
}
endif;
if ( ! function_exists( 'et_pb_get_audio_player' ) ) :
function et_pb_get_audio_player() {
$output = sprintf(
'
%1$s
',
do_shortcode( '[audio]' )
);
return $output;
}
endif;
/*
* Displays post audio, quote and link post formats content
*/
if ( ! function_exists( 'et_divi_post_format_content' ) ) :
function et_divi_post_format_content() {
$post_format = et_pb_post_format();
$text_color_class = et_divi_get_post_text_color();
$inline_style = et_divi_get_post_bg_inline_style();
switch ( $post_format ) {
case 'audio' :
printf(
'
',
get_the_title(),
et_pb_get_audio_player(),
esc_url( get_permalink() ),
esc_attr( $text_color_class ),
$inline_style
);
break;
case 'quote' :
printf(
'
',
et_get_blockquote_in_content(),
esc_url( get_permalink() ),
__( 'Read more', 'Divi' ),
esc_attr( $text_color_class ),
$inline_style
);
break;
case 'link' :
printf(
'
',
get_the_title(),
esc_url( get_permalink() ),
esc_url( et_get_link_url() ),
esc_html( et_get_link_url() ),
esc_attr( $text_color_class ),
$inline_style
);
break;
}
}
endif;
/**
* Extract and return the first blockquote from content.
*/
if ( ! function_exists( 'et_get_blockquote_in_content' ) ) :
function et_get_blockquote_in_content() {
global $more;
$more_default = $more;
$more = 1;
remove_filter( 'the_content', 'et_remove_blockquote_from_content' );
$content = apply_filters( 'the_content', get_the_content() );
add_filter( 'the_content', 'et_remove_blockquote_from_content' );
$more = $more_default;
if ( preg_match( '/
(.+?)<\/blockquote>/is', $content, $matches ) ) {
return $matches[0];
} else {
return false;
}
}
endif;
if ( ! function_exists( 'et_get_link_url' ) ) :
function et_get_link_url() {
if ( '' !== ( $link_url = get_post_meta( get_the_ID(), '_format_link_url', true ) ) ) {
return $link_url;
}
$content = get_the_content();
$has_url = get_url_in_content( $content );
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
endif;
if ( ! function_exists( 'et_get_first_video' ) ) :
function et_get_first_video() {
$first_video = '';
$custom_fields = get_post_custom();
$video_width = (int) apply_filters( 'et_blog_video_width', 1080 );
$video_height = (int) apply_filters( 'et_blog_video_height', 630 );
foreach ( $custom_fields as $key => $custom_field ) {
if ( 0 !== strpos( $key, '_oembed_' ) ) {
continue;
}
$first_video = $custom_field[0];
$first_video = preg_replace( '/