Guest User

Untitled

a guest
May 11th, 2015
299
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if ( ! isset( $content_width ) ) $content_width = 1080;
  4.  
  5. function et_setup_theme() {
  6. global $themename, $shortname, $et_store_options_in_one_row, $default_colorscheme;
  7. $themename = 'Divi';
  8. $shortname = 'divi';
  9. $et_store_options_in_one_row = true;
  10.  
  11. $default_colorscheme = "Default";
  12.  
  13. $template_directory = get_template_directory();
  14.  
  15. require_once( $template_directory . '/epanel/custom_functions.php' );
  16.  
  17. require_once( $template_directory . '/includes/functions/comments.php' );
  18.  
  19. require_once( $template_directory . '/includes/functions/sidebars.php' );
  20.  
  21. load_theme_textdomain( 'Divi', $template_directory . '/lang' );
  22.  
  23. require_once( $template_directory . '/epanel/core_functions.php' );
  24.  
  25. require_once( $template_directory . '/epanel/post_thumbnails_divi.php' );
  26.  
  27. include( $template_directory . '/includes/widgets.php' );
  28.  
  29. register_nav_menus( array(
  30. 'primary-menu' => __( 'Primary Menu', 'Divi' ),
  31. 'secondary-menu' => __( 'Secondary Menu', 'Divi' ),
  32. 'footer-menu' => __( 'Footer Menu', 'Divi' ),
  33. ) );
  34.  
  35. // don't display the empty title bar if the widget title is not set
  36. remove_filter( 'widget_title', 'et_widget_force_title' );
  37.  
  38. remove_filter( 'body_class', 'et_add_fullwidth_body_class' );
  39.  
  40. add_action( 'wp_enqueue_scripts', 'et_add_responsive_shortcodes_css', 11 );
  41.  
  42. add_theme_support( 'post-formats', array(
  43. 'video', 'audio', 'quote', 'gallery', 'link'
  44. ) );
  45.  
  46. add_theme_support( 'woocommerce' );
  47.  
  48. remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
  49.  
  50. remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
  51. add_action( 'woocommerce_before_main_content', 'et_divi_output_content_wrapper', 10 );
  52.  
  53. remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
  54. add_action( 'woocommerce_after_main_content', 'et_divi_output_content_wrapper_end', 10 );
  55.  
  56. remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
  57.  
  58. // deactivate page templates and custom import functions
  59. remove_action( 'init', 'et_activate_features' );
  60. }
  61. add_action( 'after_setup_theme', 'et_setup_theme' );
  62.  
  63. if ( ! function_exists( 'et_divi_fonts_url' ) ) :
  64. function et_divi_fonts_url() {
  65. $fonts_url = '';
  66.  
  67. /* Translators: If there are characters in your language that are not
  68. * supported by Open Sans, translate this to 'off'. Do not translate
  69. * into your own language.
  70. */
  71. $open_sans = _x( 'on', 'Open Sans font: on or off', 'Divi' );
  72.  
  73. if ( 'off' !== $open_sans ) {
  74. $font_families = array();
  75.  
  76. if ( 'off' !== $open_sans )
  77. $font_families[] = 'Open+Sans:300italic,400italic,700italic,800italic,400,300,700,800';
  78.  
  79. $protocol = is_ssl() ? 'https' : 'http';
  80. $query_args = array(
  81. 'family' => implode( '%7C', $font_families ),
  82. 'subset' => 'latin,latin-ext',
  83. );
  84. $fonts_url = add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" );
  85. }
  86.  
  87. return $fonts_url;
  88. }
  89. endif;
  90.  
  91. function et_divi_load_fonts() {
  92. $fonts_url = et_divi_fonts_url();
  93. if ( ! empty( $fonts_url ) )
  94. wp_enqueue_style( 'divi-fonts', esc_url_raw( $fonts_url ), array(), null );
  95. }
  96. add_action( 'wp_enqueue_scripts', 'et_divi_load_fonts' );
  97.  
  98. function et_add_home_link( $args ) {
  99. // add Home link to the custom menu WP-Admin page
  100. $args['show_home'] = true;
  101. return $args;
  102. }
  103. add_filter( 'wp_page_menu_args', 'et_add_home_link' );
  104.  
  105. function et_divi_load_scripts_styles(){
  106. global $wp_styles;
  107.  
  108. $template_dir = get_template_directory_uri();
  109.  
  110. $theme_version = et_get_theme_version();
  111.  
  112. if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
  113. wp_enqueue_script( 'comment-reply' );
  114.  
  115. wp_register_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(), $theme_version, true );
  116. wp_enqueue_script( 'divi-fitvids', $template_dir . '/js/jquery.fitvids.js', array( 'jquery' ), $theme_version, true );
  117. wp_enqueue_script( 'waypoints', $template_dir . '/js/waypoints.min.js', array( 'jquery' ), $theme_version, true );
  118. wp_enqueue_script( 'magnific-popup', $template_dir . '/js/jquery.magnific-popup.js', array( 'jquery' ), $theme_version, true );
  119. wp_register_script( 'hashchange', $template_dir . '/js/jquery.hashchange.js', array( 'jquery' ), $theme_version, true );
  120. wp_register_script( 'imagesloaded', $template_dir . '/js/imagesloaded.js', array( 'jquery' ), $theme_version, true );
  121. wp_register_script( 'jquery-masonry-3', $template_dir . '/js/masonry.js', array( 'jquery', 'imagesloaded' ), $theme_version, true );
  122. wp_register_script( 'easypiechart', $template_dir . '/js/jquery.easypiechart.js', array( 'jquery' ), $theme_version, true );
  123. wp_enqueue_script( 'divi-custom-script', $template_dir . '/js/custom.js', array( 'jquery' ), $theme_version, true );
  124. wp_localize_script( 'divi-custom-script', 'et_custom', array(
  125. 'ajaxurl' => admin_url( 'admin-ajax.php' ),
  126. 'images_uri' => get_template_directory_uri() . '/images',
  127. 'et_load_nonce' => wp_create_nonce( 'et_load_nonce' ),
  128. 'subscription_failed' => __( 'Please, check the fields below to make sure you entered the correct information.', 'Divi' ),
  129. 'fill' => esc_html__( 'Fill', 'Divi' ),
  130. 'field' => esc_html__( 'field', 'Divi' ),
  131. 'invalid' => esc_html__( 'Invalid email', 'Divi' ),
  132. 'captcha' => esc_html__( 'Captcha', 'Divi' ),
  133. 'prev' => esc_html__( 'Prev', 'Divi' ),
  134. 'previous' => esc_html__( 'Previous', 'Divi' ),
  135. 'next' => esc_html__( 'Next', 'Divi' ),
  136. ) );
  137.  
  138. if ( 'on' === et_get_option( 'divi_smooth_scroll', false ) ) {
  139. wp_enqueue_script( 'smooth-scroll', $template_dir . '/js/smoothscroll.js', array( 'jquery' ), $theme_version, true );
  140. }
  141.  
  142. $et_gf_enqueue_fonts = array();
  143. $et_gf_heading_font = sanitize_text_field( et_get_option( 'heading_font', 'none' ) );
  144. $et_gf_body_font = sanitize_text_field( et_get_option( 'body_font', 'none' ) );
  145.  
  146. $site_domain = get_locale();
  147. $et_one_font_languages = et_get_one_font_languages();
  148.  
  149. if ( 'none' != $et_gf_heading_font ) $et_gf_enqueue_fonts[] = $et_gf_heading_font;
  150. if ( 'none' != $et_gf_body_font ) $et_gf_enqueue_fonts[] = $et_gf_body_font;
  151.  
  152. if ( isset( $et_one_font_languages[$site_domain] ) ) {
  153. $et_gf_font_name_slug = strtolower( str_replace( ' ', '-', $et_one_font_languages[$site_domain]['language_name'] ) );
  154. wp_enqueue_style( 'et-gf-' . $et_gf_font_name_slug, $et_one_font_languages[$site_domain]['google_font_url'], array(), null );
  155. } else if ( ! empty( $et_gf_enqueue_fonts ) ) {
  156. et_gf_enqueue_fonts( $et_gf_enqueue_fonts );
  157. }
  158.  
  159. /*
  160. * Loads the main stylesheet.
  161. */
  162. wp_enqueue_style( 'divi-style', get_stylesheet_uri(), array(), $theme_version );
  163. }
  164. add_action( 'wp_enqueue_scripts', 'et_divi_load_scripts_styles' );
  165.  
  166. function et_add_mobile_navigation(){
  167. printf(
  168. '<div id="et_mobile_nav_menu">
  169. <a href="#" class="mobile_nav closed">
  170. <span class="select_page">%1$s</span>
  171. <span class="mobile_menu_bar"></span>
  172. </a>
  173. </div>',
  174. esc_html__( 'Select Page', 'Divi' )
  175. );
  176. }
  177. add_action( 'et_header_top', 'et_add_mobile_navigation' );
  178.  
  179. function et_add_viewport_meta(){
  180. echo '<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />';
  181. }
  182. add_action( 'wp_head', 'et_add_viewport_meta' );
  183.  
  184. function et_remove_additional_stylesheet( $stylesheet ){
  185. global $default_colorscheme;
  186. return $default_colorscheme;
  187. }
  188. add_filter( 'et_get_additional_color_scheme', 'et_remove_additional_stylesheet' );
  189.  
  190. if ( ! function_exists( 'et_list_pings' ) ) :
  191. function et_list_pings($comment, $args, $depth) {
  192. $GLOBALS['comment'] = $comment; ?>
  193. <li id="comment-<?php comment_ID(); ?>"><?php comment_author_link(); ?> - <?php comment_excerpt(); ?>
  194. <?php }
  195. endif;
  196.  
  197. if ( ! function_exists( 'et_get_theme_version' ) ) :
  198. function et_get_theme_version() {
  199. $theme_info = wp_get_theme();
  200.  
  201. if ( is_child_theme() ) {
  202. $theme_info = wp_get_theme( $theme_info->parent_theme );
  203. }
  204.  
  205. $theme_version = $theme_info->display( 'Version' );
  206.  
  207. return $theme_version;
  208. }
  209. endif;
  210.  
  211. if ( ! function_exists( 'et_get_the_author_posts_link' ) ) :
  212. function et_get_the_author_posts_link(){
  213. global $authordata, $themename;
  214.  
  215. $link = sprintf(
  216. '<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
  217. esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
  218. esc_attr( sprintf( __( 'Posts by %s', $themename ), get_the_author() ) ),
  219. get_the_author()
  220. );
  221. return apply_filters( 'the_author_posts_link', $link );
  222. }
  223. endif;
  224.  
  225. if ( ! function_exists( 'et_get_comments_popup_link' ) ) :
  226. function et_get_comments_popup_link( $zero = false, $one = false, $more = false ){
  227. global $themename;
  228.  
  229. $id = get_the_ID();
  230. $number = get_comments_number( $id );
  231.  
  232. if ( 0 == $number && !comments_open() && !pings_open() ) return;
  233.  
  234. if ( $number > 1 )
  235. $output = str_replace('%', number_format_i18n($number), ( false === $more ) ? __('% Comments', $themename) : $more);
  236. elseif ( $number == 0 )
  237. $output = ( false === $zero ) ? __('No Comments',$themename) : $zero;
  238. else // must be one
  239. $output = ( false === $one ) ? __('1 Comment', $themename) : $one;
  240.  
  241. return '<span class="comments-number">' . '<a href="' . esc_url( get_permalink() . '#respond' ) . '">' . apply_filters('comments_number', $output, $number) . '</a>' . '</span>';
  242. }
  243. endif;
  244.  
  245. if ( ! function_exists( 'et_postinfo_meta' ) ) :
  246. function et_postinfo_meta( $postinfo, $date_format, $comment_zero, $comment_one, $comment_more ){
  247. global $themename;
  248.  
  249. $postinfo_meta = '';
  250.  
  251. if ( in_array( 'author', $postinfo ) )
  252. $postinfo_meta .= ' ' . esc_html__('by',$themename) . ' ' . et_get_the_author_posts_link();
  253.  
  254. if ( in_array( 'date', $postinfo ) ) {
  255. if ( in_array( 'author', $postinfo ) ) $postinfo_meta .= ' | ';
  256. $postinfo_meta .= get_the_time( wp_unslash( $date_format ) );
  257. }
  258.  
  259. if ( in_array( 'categories', $postinfo ) ){
  260. if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) ) $postinfo_meta .= ' | ';
  261. $postinfo_meta .= get_the_category_list(', ');
  262. }
  263.  
  264. if ( in_array( 'comments', $postinfo ) ){
  265. if ( in_array( 'author', $postinfo ) || in_array( 'date', $postinfo ) || in_array( 'categories', $postinfo ) ) $postinfo_meta .= ' | ';
  266. $postinfo_meta .= et_get_comments_popup_link( $comment_zero, $comment_one, $comment_more );
  267. }
  268.  
  269. echo $postinfo_meta;
  270. }
  271. endif;
  272.  
  273. function et_add_post_meta_box() {
  274. add_meta_box( 'et_settings_meta_box', __( 'ET Settings', 'Divi' ), 'et_single_settings_meta_box', 'page', 'side', 'high' );
  275. add_meta_box( 'et_settings_meta_box', __( 'ET Settings', 'Divi' ), 'et_single_settings_meta_box', 'post', 'side', 'high' );
  276. add_meta_box( 'et_settings_meta_box', __( 'ET Settings', 'Divi' ), 'et_single_settings_meta_box', 'product', 'side', 'high' );
  277. add_meta_box( 'et_settings_meta_box', __( 'ET Settings', 'Divi' ), 'et_single_settings_meta_box', 'project', 'side', 'high' );
  278. }
  279. add_action( 'add_meta_boxes', 'et_add_post_meta_box' );
  280.  
  281. function et_pb_register_posttypes() {
  282. $labels = array(
  283. 'name' => __( 'Projects', 'Divi' ),
  284. 'singular_name' => __( 'Project', 'Divi' ),
  285. 'add_new' => __( 'Add New', 'Divi' ),
  286. 'add_new_item' => __( 'Add New Project', 'Divi' ),
  287. 'edit_item' => __( 'Edit Project', 'Divi' ),
  288. 'new_item' => __( 'New Project', 'Divi' ),
  289. 'all_items' => __( 'All Projects', 'Divi' ),
  290. 'view_item' => __( 'View Project', 'Divi' ),
  291. 'search_items' => __( 'Search Projects', 'Divi' ),
  292. 'not_found' => __( 'Nothing found', 'Divi' ),
  293. 'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
  294. 'parent_item_colon' => '',
  295. );
  296.  
  297. $args = array(
  298. 'labels' => $labels,
  299. 'public' => true,
  300. 'publicly_queryable' => true,
  301. 'show_ui' => true,
  302. 'can_export' => true,
  303. 'show_in_nav_menus' => true,
  304. 'query_var' => true,
  305. 'has_archive' => true,
  306. 'rewrite' => apply_filters( 'et_project_posttype_rewrite_args', array(
  307. 'feeds' => true,
  308. 'slug' => 'project',
  309. 'with_front' => false,
  310. ) ),
  311. 'capability_type' => 'post',
  312. 'hierarchical' => false,
  313. 'menu_position' => null,
  314. 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
  315. );
  316.  
  317. register_post_type( 'project', apply_filters( 'et_project_posttype_args', $args ) );
  318.  
  319. $labels = array(
  320. 'name' => __( 'Categories', 'Divi' ),
  321. 'singular_name' => __( 'Category', 'Divi' ),
  322. 'search_items' => __( 'Search Categories', 'Divi' ),
  323. 'all_items' => __( 'All Categories', 'Divi' ),
  324. 'parent_item' => __( 'Parent Category', 'Divi' ),
  325. 'parent_item_colon' => __( 'Parent Category:', 'Divi' ),
  326. 'edit_item' => __( 'Edit Category', 'Divi' ),
  327. 'update_item' => __( 'Update Category', 'Divi' ),
  328. 'add_new_item' => __( 'Add New Category', 'Divi' ),
  329. 'new_item_name' => __( 'New Category Name', 'Divi' ),
  330. 'menu_name' => __( 'Categories', 'Divi' ),
  331. );
  332.  
  333. register_taxonomy( 'project_category', array( 'project' ), array(
  334. 'hierarchical' => true,
  335. 'labels' => $labels,
  336. 'show_ui' => true,
  337. 'show_admin_column' => true,
  338. 'query_var' => true,
  339. ) );
  340.  
  341. $labels = array(
  342. 'name' => __( 'Tags', 'Divi' ),
  343. 'singular_name' => __( 'Tag', 'Divi' ),
  344. 'search_items' => __( 'Search Tags', 'Divi' ),
  345. 'all_items' => __( 'All Tags', 'Divi' ),
  346. 'parent_item' => __( 'Parent Tag', 'Divi' ),
  347. 'parent_item_colon' => __( 'Parent Tag:', 'Divi' ),
  348. 'edit_item' => __( 'Edit Tag', 'Divi' ),
  349. 'update_item' => __( 'Update Tag', 'Divi' ),
  350. 'add_new_item' => __( 'Add New Tag', 'Divi' ),
  351. 'new_item_name' => __( 'New Tag Name', 'Divi' ),
  352. 'menu_name' => __( 'Tags', 'Divi' ),
  353. );
  354.  
  355. register_taxonomy( 'project_tag', array( 'project' ), array(
  356. 'hierarchical' => false,
  357. 'labels' => $labels,
  358. 'show_ui' => true,
  359. 'show_admin_column' => true,
  360. 'query_var' => true,
  361. ) );
  362.  
  363.  
  364. $labels = array(
  365. 'name' => _x( 'Layouts', 'Layout type general name', 'Divi' ),
  366. 'singular_name' => _x( 'Layout', 'Layout type singular name', 'Divi' ),
  367. 'add_new' => _x( 'Add New', 'Layout item', 'Divi' ),
  368. 'add_new_item' => __( 'Add New Layout', 'Divi' ),
  369. 'edit_item' => __( 'Edit Layout', 'Divi' ),
  370. 'new_item' => __( 'New Layout', 'Divi' ),
  371. 'all_items' => __( 'All Layouts', 'Divi' ),
  372. 'view_item' => __( 'View Layout', 'Divi' ),
  373. 'search_items' => __( 'Search Layouts', 'Divi' ),
  374. 'not_found' => __( 'Nothing found', 'Divi' ),
  375. 'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
  376. 'parent_item_colon' => '',
  377. );
  378.  
  379. $args = array(
  380. 'labels' => $labels,
  381. 'public' => false,
  382. 'can_export' => true,
  383. 'query_var' => false,
  384. 'has_archive' => false,
  385. 'capability_type' => 'post',
  386. 'hierarchical' => false,
  387. 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
  388. );
  389.  
  390. register_post_type( 'et_pb_layout', apply_filters( 'et_pb_layout_args', $args ) );
  391. }
  392. add_action( 'init', 'et_pb_register_posttypes', 0 );
  393.  
  394. if ( ! function_exists( 'et_pb_portfolio_meta_box' ) ) :
  395. function et_pb_portfolio_meta_box() { ?>
  396. <div class="et_project_meta">
  397. <strong class="et_project_meta_title"><?php echo esc_html__( 'Skills', 'Divi' ); ?></strong>
  398. <p><?php echo get_the_term_list( get_the_ID(), 'project_tag', '', ', ' ); ?></p>
  399.  
  400. <strong class="et_project_meta_title"><?php echo esc_html__( 'Posted on', 'Divi' ); ?></strong>
  401. <p><?php echo get_the_date(); ?></p>
  402. </div>
  403. <?php }
  404. endif;
  405.  
  406. if ( ! function_exists( 'et_single_settings_meta_box' ) ) :
  407. function et_single_settings_meta_box( $post ) {
  408. $post_id = get_the_ID();
  409.  
  410. wp_nonce_field( basename( __FILE__ ), 'et_settings_nonce' );
  411.  
  412. $page_layout = get_post_meta( $post_id, '_et_pb_page_layout', true );
  413.  
  414. $side_nav = get_post_meta( $post_id, '_et_pb_side_nav', true );
  415.  
  416. $page_layouts = array(
  417. 'et_right_sidebar' => __( 'Right Sidebar', 'Divi' ),
  418. 'et_left_sidebar' => __( 'Left Sidebar', 'Divi' ),
  419. 'et_full_width_page' => __( 'Full Width', 'Divi' ),
  420. );
  421.  
  422. $layouts = array(
  423. 'light' => __( 'Light', 'Divi' ),
  424. 'dark' => __( 'Dark', 'Divi' ),
  425. );
  426. $post_bg_color = ( $bg_color = get_post_meta( $post_id, '_et_post_bg_color', true ) ) && '' !== $bg_color
  427. ? $bg_color
  428. : '#ffffff';
  429. $post_use_bg_color = get_post_meta( $post_id, '_et_post_use_bg_color', true )
  430. ? true
  431. : false;
  432. $post_bg_layout = ( $layout = get_post_meta( $post_id, '_et_post_bg_layout', true ) ) && '' !== $layout
  433. ? $layout
  434. : 'light'; ?>
  435.  
  436. <p class="et_pb_page_settings et_pb_page_layout_settings">
  437. <label for="et_pb_page_layout" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Page Layout', 'Divi' ); ?>: </label>
  438.  
  439. <select id="et_pb_page_layout" name="et_pb_page_layout">
  440. <?php
  441. foreach ( $page_layouts as $layout_value => $layout_name ) {
  442. printf( '<option value="%2$s"%3$s>%1$s</option>',
  443. esc_html( $layout_name ),
  444. esc_attr( $layout_value ),
  445. selected( $layout_value, $page_layout, false )
  446. );
  447. } ?>
  448. </select>
  449. </p>
  450. <p class="et_pb_page_settings et_pb_side_nav_settings" style="display: none;">
  451. <label for="et_pb_side_nav" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Side Navigation', 'Divi' ); ?>: </label>
  452.  
  453. <select id="et_pb_side_nav" name="et_pb_side_nav">
  454. <option value="off" <?php selected( 'off', $side_nav ); ?>><?php esc_html_e( 'Off', 'Divi' ); ?></option>
  455. <option value="on" <?php selected( 'on', $side_nav ); ?>><?php esc_html_e( 'On', 'Divi' ); ?></option>
  456. </select>
  457. </p>
  458. <?php if ( in_array( $post->post_type, array( 'page', 'project' ) ) ) : ?>
  459. <p class="et_pb_page_settings" style="display: none;">
  460. <input type="hidden" id="et_pb_use_builder" name="et_pb_use_builder" value="<?php echo esc_attr( get_post_meta( $post_id, '_et_pb_use_builder', true ) ); ?>" />
  461. <textarea id="et_pb_old_content" name="et_pb_old_content"><?php echo esc_attr( get_post_meta( $post_id, '_et_pb_old_content', true ) ); ?></textarea>
  462. </p>
  463. <?php endif; ?>
  464.  
  465. <?php if ( 'post' === $post->post_type ) : ?>
  466. <p class="et_divi_quote_settings et_divi_audio_settings et_divi_link_settings et_divi_format_setting">
  467. <label for="et_post_use_bg_color" style="display: block; font-weight: bold; margin-bottom: 5px;">
  468. <input name="et_post_use_bg_color" type="checkbox" id="et_post_use_bg_color" <?php checked( $post_use_bg_color ); ?> />
  469. <?php esc_html_e( 'Use Background Color', 'Divi' ); ?></label>
  470. </p>
  471.  
  472. <p class="et_post_bg_color_setting et_divi_format_setting">
  473. <label for="et_post_bg_color" style="display: block; font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Background Color', 'Divi' ); ?>: </label>
  474. <input id="et_post_bg_color" name="et_post_bg_color" class="color-picker-hex" type="text" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value', 'Divi' ); ?>" value="<?php echo esc_attr( $post_bg_color ); ?>" data-default-color="#ffffff" />
  475. </p>
  476.  
  477. <p class="et_divi_quote_settings et_divi_audio_settings et_divi_link_settings et_divi_format_setting">
  478. <label for="et_post_bg_layout" style="font-weight: bold; margin-bottom: 5px;"><?php esc_html_e( 'Text Color', 'Divi' ); ?>: </label>
  479. <select id="et_post_bg_layout" name="et_post_bg_layout">
  480. <?php
  481. foreach ( $layouts as $layout_name => $layout_title )
  482. printf( '<option value="%s"%s>%s</option>',
  483. esc_attr( $layout_name ),
  484. selected( $layout_name, $post_bg_layout, false ),
  485. esc_html( $layout_title )
  486. );
  487. ?>
  488. </select>
  489. </p>
  490. <?php endif;
  491.  
  492. }
  493. endif;
  494.  
  495. function et_metabox_settings_save_details( $post_id, $post ){
  496. global $pagenow;
  497.  
  498. if ( 'post.php' != $pagenow ) return $post_id;
  499.  
  500. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
  501. return $post_id;
  502.  
  503. $post_type = get_post_type_object( $post->post_type );
  504. if ( ! current_user_can( $post_type->cap->edit_post, $post_id ) )
  505. return $post_id;
  506.  
  507. if ( ! isset( $_POST['et_settings_nonce'] ) || ! wp_verify_nonce( $_POST['et_settings_nonce'], basename( __FILE__ ) ) )
  508. return $post_id;
  509.  
  510. if ( isset( $_POST['et_pb_page_layout'] ) ) {
  511. update_post_meta( $post_id, '_et_pb_page_layout', sanitize_text_field( $_POST['et_pb_page_layout'] ) );
  512. } else {
  513. delete_post_meta( $post_id, '_et_pb_page_layout' );
  514. }
  515.  
  516. if ( isset( $_POST['et_pb_side_nav'] ) ) {
  517. update_post_meta( $post_id, '_et_pb_side_nav', sanitize_text_field( $_POST['et_pb_side_nav'] ) );
  518. } else {
  519. delete_post_meta( $post_id, '_et_pb_side_nav' );
  520. }
  521.  
  522. if ( isset( $_POST['et_pb_use_builder'] ) ) {
  523. update_post_meta( $post_id, '_et_pb_use_builder', sanitize_text_field( $_POST['et_pb_use_builder'] ) );
  524. } else {
  525. delete_post_meta( $post_id, '_et_pb_use_builder' );
  526. }
  527.  
  528. if ( isset( $_POST['et_pb_old_content'] ) ) {
  529. update_post_meta( $post_id, '_et_pb_old_content', $_POST['et_pb_old_content'] );
  530. } else {
  531. delete_post_meta( $post_id, '_et_pb_old_content' );
  532. }
  533.  
  534. if ( isset( $_POST['et_post_use_bg_color'] ) )
  535. update_post_meta( $post_id, '_et_post_use_bg_color', true );
  536. else
  537. delete_post_meta( $post_id, '_et_post_use_bg_color' );
  538.  
  539. if ( isset( $_POST['et_post_bg_color'] ) )
  540. update_post_meta( $post_id, '_et_post_bg_color', sanitize_text_field( $_POST['et_post_bg_color'] ) );
  541. else
  542. delete_post_meta( $post_id, '_et_post_bg_color' );
  543.  
  544. if ( isset( $_POST['et_post_bg_layout'] ) )
  545. update_post_meta( $post_id, '_et_post_bg_layout', sanitize_text_field( $_POST['et_post_bg_layout'] ) );
  546. else
  547. delete_post_meta( $post_id, '_et_post_bg_layout' );
  548. }
  549. add_action( 'save_post', 'et_metabox_settings_save_details', 10, 2 );
  550.  
  551. function et_get_one_font_languages() {
  552. $one_font_languages = array(
  553. 'he_IL' => array(
  554. 'language_name' => 'Hebrew',
  555. 'google_font_url' => '//fonts.googleapis.com/earlyaccess/alefhebrew.css',
  556. 'font_family' => "'Alef Hebrew', serif",
  557. ),
  558. 'ja' => array(
  559. 'language_name' => 'Japanese',
  560. 'google_font_url' => '//fonts.googleapis.com/earlyaccess/notosansjapanese.css',
  561. 'font_family' => "'Noto Sans Japanese', serif",
  562. ),
  563. 'ko_KR' => array(
  564. 'language_name' => 'Korean',
  565. 'google_font_url' => '//fonts.googleapis.com/earlyaccess/hanna.css',
  566. 'font_family' => "'Hanna', serif",
  567. ),
  568. 'ar' => array(
  569. 'language_name' => 'Arabic',
  570. 'google_font_url' => '//fonts.googleapis.com/earlyaccess/lateef.css',
  571. 'font_family' => "'Lateef', serif",
  572. ),
  573. 'th' => array(
  574. 'language_name' => 'Thai',
  575. 'google_font_url' => '//fonts.googleapis.com/earlyaccess/notosansthai.css',
  576. 'font_family' => "'Noto Sans Thai', serif",
  577. ),
  578. 'ms_MY' => array(
  579. 'language_name' => 'Malay',
  580. 'google_font_url' => '//fonts.googleapis.com/earlyaccess/notosansmalayalam.css',
  581. 'font_family' => "'Noto Sans Malayalam', serif",
  582. ),
  583. 'zh_CN' => array(
  584. 'language_name' => 'Chinese',
  585. 'google_font_url' => '//fonts.googleapis.com/earlyaccess/cwtexfangsong.css',
  586. 'font_family' => "'cwTeXFangSong', serif",
  587. ),
  588. );
  589.  
  590. return $one_font_languages;
  591. }
  592.  
  593. function et_divi_customize_register( $wp_customize ) {
  594. $site_domain = get_locale();
  595.  
  596. $google_fonts = et_get_google_fonts();
  597.  
  598. $et_domain_fonts = array(
  599. 'ru_RU' => 'cyrillic',
  600. 'uk' => 'cyrillic',
  601. 'bg_BG' => 'cyrillic',
  602. 'vi' => 'vietnamese',
  603. 'el' => 'greek',
  604. );
  605.  
  606. $et_one_font_languages = et_get_one_font_languages();
  607.  
  608. $font_choices = array();
  609. $font_choices['none'] = 'Default Theme Font';
  610. foreach ( $google_fonts as $google_font_name => $google_font_properties ) {
  611. if ( '' !== $site_domain && isset( $et_domain_fonts[$site_domain] ) && false === strpos( $google_font_properties['character_set'], $et_domain_fonts[$site_domain] ) ) {
  612. continue;
  613. }
  614. $font_choices[ $google_font_name ] = $google_font_name;
  615. }
  616.  
  617. $wp_customize->remove_section( 'title_tagline' );
  618.  
  619. $wp_customize->add_section( 'et_divi_settings' , array(
  620. 'title' => __( 'Theme Settings', 'Divi' ),
  621. 'priority' => 40,
  622. ) );
  623.  
  624. $wp_customize->add_section( 'et_google_fonts' , array(
  625. 'title' => __( 'Fonts', 'Divi' ),
  626. 'priority' => 50,
  627. ) );
  628.  
  629. $wp_customize->add_section( 'et_color_schemes' , array(
  630. 'title' => __( 'Schemes', 'Divi' ),
  631. 'priority' => 60,
  632. 'description' => __( 'Note: Color settings set above should be applied to the Default color scheme.', 'Divi' ),
  633. ) );
  634.  
  635. $wp_customize->add_setting( 'et_divi[link_color]', array(
  636. 'default' => '#2EA3F2',
  637. 'type' => 'option',
  638. 'capability' => 'edit_theme_options',
  639. 'transport' => 'postMessage'
  640. ) );
  641.  
  642. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[link_color]', array(
  643. 'label' => __( 'Link Color', 'Divi' ),
  644. 'section' => 'colors',
  645. 'settings' => 'et_divi[link_color]',
  646. ) ) );
  647.  
  648. $wp_customize->add_setting( 'et_divi[font_color]', array(
  649. 'default' => '#666666',
  650. 'type' => 'option',
  651. 'capability' => 'edit_theme_options',
  652. 'transport' => 'postMessage'
  653. ) );
  654.  
  655. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[font_color]', array(
  656. 'label' => __( 'Main Font Color', 'Divi' ),
  657. 'section' => 'colors',
  658. 'settings' => 'et_divi[font_color]',
  659. ) ) );
  660.  
  661. $wp_customize->add_setting( 'et_divi[accent_color]', array(
  662. 'default' => '#2EA3F2',
  663. 'type' => 'option',
  664. 'capability' => 'edit_theme_options',
  665. 'transport' => 'postMessage'
  666. ) );
  667.  
  668. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[accent_color]', array(
  669. 'label' => __( 'Accent Color', 'Divi' ),
  670. 'section' => 'colors',
  671. 'settings' => 'et_divi[accent_color]',
  672. ) ) );
  673.  
  674. $wp_customize->add_setting( 'et_divi[footer_bg]', array(
  675. 'default' => '#222222',
  676. 'type' => 'option',
  677. 'capability' => 'edit_theme_options',
  678. 'transport' => 'postMessage'
  679. ) );
  680.  
  681. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[footer_bg]', array(
  682. 'label' => __( 'Footer Background Color', 'Divi' ),
  683. 'section' => 'colors',
  684. 'settings' => 'et_divi[footer_bg]',
  685. ) ) );
  686.  
  687. $wp_customize->add_setting( 'et_divi[menu_link]', array(
  688. 'default' => '#666666',
  689. 'type' => 'option',
  690. 'capability' => 'edit_theme_options',
  691. 'transport' => 'postMessage'
  692. ) );
  693.  
  694. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[menu_link]', array(
  695. 'label' => __( 'Menu Links Color', 'Divi' ),
  696. 'section' => 'colors',
  697. 'settings' => 'et_divi[menu_link]',
  698. ) ) );
  699.  
  700. $wp_customize->add_setting( 'et_divi[menu_link_active]', array(
  701. 'default' => '#2EA3F2',
  702. 'type' => 'option',
  703. 'capability' => 'edit_theme_options',
  704. 'transport' => 'postMessage'
  705. ) );
  706.  
  707. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[menu_link_active]', array(
  708. 'label' => __( 'Active Menu Link Color', 'Divi' ),
  709. 'section' => 'colors',
  710. 'settings' => 'et_divi[menu_link_active]',
  711. ) ) );
  712.  
  713. $wp_customize->add_setting( 'et_divi[boxed_layout]', array(
  714. 'type' => 'option',
  715. 'capability' => 'edit_theme_options',
  716. 'transport' => 'postMessage',
  717. ) );
  718.  
  719. $wp_customize->add_control( 'et_divi[boxed_layout]', array(
  720. 'label' => __( 'Boxed Layout', 'Divi' ),
  721. 'section' => 'et_divi_settings',
  722. 'type' => 'checkbox',
  723. 'priority' => 10,
  724. ) );
  725.  
  726. $wp_customize->add_setting( 'et_divi[cover_background]', array(
  727. 'default' => 'on',
  728. 'type' => 'option',
  729. 'capability' => 'edit_theme_options',
  730. 'transport' => 'postMessage',
  731. ) );
  732.  
  733. $wp_customize->add_control( 'et_divi[cover_background]', array(
  734. 'label' => __( 'Stretch Background Image', 'Divi' ),
  735. 'section' => 'et_divi_settings',
  736. 'type' => 'checkbox',
  737. 'priority' => 10,
  738. ) );
  739.  
  740. $wp_customize->add_setting( 'et_divi[vertical_nav]', array(
  741. 'type' => 'option',
  742. 'capability' => 'edit_theme_options',
  743. 'transport' => 'postMessage',
  744. ) );
  745.  
  746. $wp_customize->add_control( 'et_divi[vertical_nav]', array(
  747. 'label' => __( 'Vertical Navigation', 'Divi' ),
  748. 'section' => 'et_divi_settings',
  749. 'type' => 'checkbox',
  750. 'priority' => 20,
  751. ) );
  752.  
  753. $wp_customize->add_setting( 'et_divi[show_header_social_icons]', array(
  754. 'type' => 'option',
  755. 'capability' => 'edit_theme_options',
  756. 'transport' => 'postMessage',
  757. ) );
  758.  
  759. $wp_customize->add_control( 'et_divi[show_header_social_icons]', array(
  760. 'label' => __( 'Show Social Icons in Header', 'Divi' ),
  761. 'section' => 'et_divi_settings',
  762. 'type' => 'checkbox',
  763. 'priority' => 30,
  764. ) );
  765.  
  766. $wp_customize->add_setting( 'et_divi[show_footer_social_icons]', array(
  767. 'default' => 'on',
  768. 'type' => 'option',
  769. 'capability' => 'edit_theme_options',
  770. 'transport' => 'postMessage',
  771. ) );
  772.  
  773. $wp_customize->add_control( 'et_divi[show_footer_social_icons]', array(
  774. 'label' => __( 'Show Social Icons in Footer', 'Divi' ),
  775. 'section' => 'et_divi_settings',
  776. 'type' => 'checkbox',
  777. 'priority' => 40,
  778. ) );
  779.  
  780. $wp_customize->add_setting( 'et_divi[show_search_icon]', array(
  781. 'default' => 'on',
  782. 'type' => 'option',
  783. 'capability' => 'edit_theme_options',
  784. 'transport' => 'postMessage',
  785. ) );
  786.  
  787. $wp_customize->add_control( 'et_divi[show_search_icon]', array(
  788. 'label' => __( 'Show Search Icon', 'Divi' ),
  789. 'section' => 'et_divi_settings',
  790. 'type' => 'checkbox',
  791. 'priority' => 50,
  792. ) );
  793.  
  794. $wp_customize->add_setting( 'et_divi[header_style]', array(
  795. 'default' => 'left',
  796. 'type' => 'option',
  797. 'capability' => 'edit_theme_options',
  798. 'transport' => 'postMessage',
  799. ) );
  800.  
  801. $wp_customize->add_control( 'et_divi[header_style]', array(
  802. 'label' => __( 'Header Style', 'Divi' ),
  803. 'section' => 'et_divi_settings',
  804. 'type' => 'select',
  805. 'choices' => array(
  806. 'left' => __( 'Default', 'Divi' ),
  807. 'centered' => __( 'Centered', 'Divi' ),
  808. ),
  809. 'priority' => 55,
  810. ) );
  811.  
  812. $wp_customize->add_setting( 'et_divi[phone_number]', array(
  813. 'type' => 'option',
  814. 'capability' => 'edit_theme_options',
  815. 'transport' => 'postMessage',
  816. ) );
  817.  
  818. $wp_customize->add_control( 'et_divi[phone_number]', array(
  819. 'label' => __( 'Phone Number', 'Divi' ),
  820. 'section' => 'et_divi_settings',
  821. 'type' => 'text',
  822. 'priority' => 60,
  823. ) );
  824.  
  825. $wp_customize->add_setting( 'et_divi[header_email]', array(
  826. 'type' => 'option',
  827. 'capability' => 'edit_theme_options',
  828. 'transport' => 'postMessage',
  829. ) );
  830.  
  831. $wp_customize->add_control( 'et_divi[header_email]', array(
  832. 'label' => __( 'Email', 'Divi' ),
  833. 'section' => 'et_divi_settings',
  834. 'type' => 'text',
  835. 'priority' => 70,
  836. ) );
  837.  
  838. $wp_customize->add_setting( 'et_divi[primary_nav_bg]', array(
  839. 'default' => '#ffffff',
  840. 'type' => 'option',
  841. 'capability' => 'edit_theme_options',
  842. 'transport' => 'postMessage'
  843. ) );
  844.  
  845. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[primary_nav_bg]', array(
  846. 'label' => __( 'Primary Navigation Background', 'Divi' ),
  847. 'section' => 'colors',
  848. 'settings' => 'et_divi[primary_nav_bg]',
  849. 'priority' => 80,
  850. ) ) );
  851.  
  852. $wp_customize->add_setting( 'et_divi[primary_nav_text_color]', array(
  853. 'default' => 'dark',
  854. 'type' => 'option',
  855. 'capability' => 'edit_theme_options',
  856. 'transport' => 'postMessage',
  857. ) );
  858.  
  859. $wp_customize->add_control( 'et_divi[primary_nav_text_color]', array(
  860. 'label' => __( 'Primary Navigation Text Color', 'Divi' ),
  861. 'section' => 'et_divi_settings',
  862. 'type' => 'select',
  863. 'choices' => array(
  864. 'dark' => __( 'Dark', 'Divi' ),
  865. 'light' => __( 'Light', 'Divi' ),
  866. ),
  867. 'priority' => 90,
  868. ) );
  869.  
  870. $wp_customize->add_setting( 'et_divi[secondary_nav_bg]', array(
  871. 'default' => et_get_option( 'accent_color', '#2EA3F2' ),
  872. 'type' => 'option',
  873. 'capability' => 'edit_theme_options',
  874. 'transport' => 'postMessage'
  875. ) );
  876.  
  877. $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'et_divi[secondary_nav_bg]', array(
  878. 'label' => __( 'Secondary Navigation Background', 'Divi' ),
  879. 'section' => 'colors',
  880. 'settings' => 'et_divi[secondary_nav_bg]',
  881. 'priority' => 100,
  882. ) ) );
  883.  
  884. $wp_customize->add_setting( 'et_divi[secondary_nav_text_color]', array(
  885. 'default' => 'light',
  886. 'type' => 'option',
  887. 'capability' => 'edit_theme_options',
  888. 'transport' => 'postMessage',
  889. ) );
  890.  
  891. $wp_customize->add_control( 'et_divi[secondary_nav_text_color]', array(
  892. 'label' => __( 'Secondary Navigation Text Color', 'Divi' ),
  893. 'section' => 'et_divi_settings',
  894. 'type' => 'select',
  895. 'choices' => array(
  896. 'dark' => __( 'Dark', 'Divi' ),
  897. 'light' => __( 'Light', 'Divi' ),
  898. ),
  899. 'priority' => 110,
  900. ) );
  901.  
  902. if ( ! isset( $et_one_font_languages[$site_domain] ) ) {
  903. $wp_customize->add_setting( 'et_divi[heading_font]', array(
  904. 'default' => 'none',
  905. 'type' => 'option',
  906. 'capability' => 'edit_theme_options',
  907. 'transport' => 'postMessage'
  908. ) );
  909.  
  910. $wp_customize->add_control( 'et_divi[heading_font]', array(
  911. 'label' => __( 'Header Font', 'Divi' ),
  912. 'section' => 'et_google_fonts',
  913. 'settings' => 'et_divi[heading_font]',
  914. 'type' => 'select',
  915. 'choices' => $font_choices
  916. ) );
  917.  
  918. $wp_customize->add_setting( 'et_divi[body_font]', array(
  919. 'default' => 'none',
  920. 'type' => 'option',
  921. 'capability' => 'edit_theme_options',
  922. 'transport' => 'postMessage'
  923. ) );
  924.  
  925. $wp_customize->add_control( 'et_divi[body_font]', array(
  926. 'label' => __( 'Body Font', 'Divi' ),
  927. 'section' => 'et_google_fonts',
  928. 'settings' => 'et_divi[body_font]',
  929. 'type' => 'select',
  930. 'choices' => $font_choices
  931. ) );
  932. }
  933.  
  934. $wp_customize->add_setting( 'et_divi[color_schemes]', array(
  935. 'default' => 'none',
  936. 'type' => 'option',
  937. 'capability' => 'edit_theme_options',
  938. 'transport' => 'postMessage'
  939. ) );
  940.  
  941. $wp_customize->add_control( 'et_divi[color_schemes]', array(
  942. 'label' => __( 'Color Schemes', 'Divi' ),
  943. 'section' => 'et_color_schemes',
  944. 'settings' => 'et_divi[color_schemes]',
  945. 'type' => 'select',
  946. 'choices' => array(
  947. 'none' => __( 'Default', 'Divi' ),
  948. 'green' => __( 'Green', 'Divi' ),
  949. 'orange' => __( 'Orange', 'Divi' ),
  950. 'pink' => __( 'Pink', 'Divi' ),
  951. 'red' => __( 'Red', 'Divi' ),
  952. ),
  953. ) );
  954. }
  955. add_action( 'customize_register', 'et_divi_customize_register' );
  956.  
  957. function et_divi_customize_preview_js() {
  958. wp_enqueue_script( 'divi-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), false, true );
  959. }
  960. add_action( 'customize_preview_init', 'et_divi_customize_preview_js' );
  961.  
  962. function et_divi_add_customizer_css(){ ?>
  963. <style>
  964. a { color: <?php echo esc_html( et_get_option( 'link_color', '#2EA3F2' ) ); ?>; }
  965.  
  966. body { color: <?php echo esc_html( et_get_option( 'font_color', '#666666' ) ); ?>; }
  967.  
  968. .et_pb_counter_amount, .et_pb_featured_table .et_pb_pricing_heading, .et_quote_content, .et_link_content, .et_audio_content { background-color: <?php echo esc_html( et_get_option( 'accent_color', '#2EA3F2' ) ); ?>; }
  969.  
  970. #main-header, #main-header .nav li ul, .et-search-form, #main-header .et_mobile_menu { background-color: <?php echo esc_html( et_get_option( 'primary_nav_bg', '#ffffff' ) ); ?>; }
  971.  
  972. #top-header, #et-secondary-nav li ul { background-color: <?php echo esc_html( et_get_option( 'secondary_nav_bg', et_get_option( 'accent_color', '#2EA3F2' ) ) ); ?>; }
  973.  
  974. .woocommerce a.button.alt, .woocommerce-page a.button.alt, .woocommerce button.button.alt, .woocommerce-page button.button.alt, .woocommerce input.button.alt, .woocommerce-page input.button.alt, .woocommerce #respond input#submit.alt, .woocommerce-page #respond input#submit.alt, .woocommerce #content input.button.alt, .woocommerce-page #content input.button.alt, .woocommerce a.button, .woocommerce-page a.button, .woocommerce button.button, .woocommerce-page button.button, .woocommerce input.button, .woocommerce-page input.button, .woocommerce #respond input#submit, .woocommerce-page #respond input#submit, .woocommerce #content input.button, .woocommerce-page #content input.button, .woocommerce-message, .woocommerce-error, .woocommerce-info { background: <?php echo esc_html( et_get_option( 'accent_color', '#2EA3F2' ) ); ?> !important; }
  975.  
  976. #et_search_icon:hover, .mobile_menu_bar:before, .footer-widget h4, .et-social-icon a:hover, .comment-reply-link, .form-submit input, .et_pb_sum, .et_pb_pricing li a, .et_pb_pricing_table_button, .et_overlay:before, .entry-summary p.price ins, .woocommerce div.product span.price, .woocommerce-page div.product span.price, .woocommerce #content div.product span.price, .woocommerce-page #content div.product span.price, .woocommerce div.product p.price, .woocommerce-page div.product p.price, .woocommerce #content div.product p.price, .woocommerce-page #content div.product p.price, .et_pb_member_social_links a:hover { color: <?php echo esc_html( et_get_option( 'accent_color', '#2EA3F2' ) ); ?> !important; }
  977.  
  978. .woocommerce .star-rating span:before, .woocommerce-page .star-rating span:before, .et_pb_widget li a:hover, .et_pb_bg_layout_light .et_pb_promo_button, .et_pb_bg_layout_light .et_pb_more_button, .et_pb_filterable_portfolio .et_pb_portfolio_filters li a.active, .et_pb_filterable_portfolio .et_pb_portofolio_pagination ul li a.active, .et_pb_gallery .et_pb_gallery_pagination ul li a.active, .wp-pagenavi span.current, .wp-pagenavi a:hover, .et_pb_contact_submit, .et_password_protected_form .et_submit_button, .et_pb_bg_layout_light .et_pb_newsletter_button, .nav-single a, .posted_in a { color: <?php echo esc_html( et_get_option( 'accent_color', '#2EA3F2' ) ); ?> !important; }
  979.  
  980. .et-search-form, .nav li ul, .et_mobile_menu, .footer-widget li:before, .et_pb_pricing li:before, blockquote { border-color: <?php echo esc_html( et_get_option( 'accent_color', '#2EA3F2' ) ); ?>; }
  981.  
  982. #main-footer { background-color: <?php echo esc_html( et_get_option( 'footer_bg', '#222222' ) ); ?>; }
  983.  
  984. #top-menu a { color: <?php echo esc_html( et_get_option( 'menu_link', '#666666' ) ); ?>; }
  985.  
  986. #top-menu li.current-menu-ancestor > a, #top-menu li.current-menu-item > a, .bottom-nav li.current-menu-item > a { color: <?php echo esc_html( et_get_option( 'menu_link_active', '#2EA3F2' ) ); ?>; }
  987.  
  988. <?php
  989. $et_gf_heading_font = sanitize_text_field( et_get_option( 'heading_font', 'none' ) );
  990. $et_gf_body_font = sanitize_text_field( et_get_option( 'body_font', 'none' ) );
  991.  
  992. $site_domain = get_locale();
  993.  
  994. $et_one_font_languages = et_get_one_font_languages();
  995.  
  996. if ( isset( $et_one_font_languages[$site_domain] ) ) {
  997. printf( '%s { font-family: %s; }',
  998. 'h1, h2, h3, h4, h5, h6, body, input, textarea, select',
  999. $et_one_font_languages[$site_domain]['font_family']
  1000. );
  1001. } else if ( 'none' != $et_gf_heading_font || 'none' != $et_gf_body_font ) {
  1002. if ( 'none' != $et_gf_heading_font ) {
  1003. et_gf_attach_font( $et_gf_heading_font, 'h1, h2, h3, h4, h5, h6' );
  1004. }
  1005.  
  1006. if ( 'none' != $et_gf_body_font ) {
  1007. et_gf_attach_font( $et_gf_body_font, 'body, input, textarea, select' );
  1008. }
  1009. }
  1010. ?>
  1011. </style>
  1012. <?php }
  1013. add_action( 'wp_head', 'et_divi_add_customizer_css' );
  1014. add_action( 'customize_controls_print_styles', 'et_divi_add_customizer_css' );
  1015.  
  1016. /*
  1017. * Adds color scheme class to the body tag
  1018. */
  1019. function et_customizer_color_scheme_class( $body_class ) {
  1020. $color_scheme = et_get_option( 'color_schemes', 'none' );
  1021. $color_scheme_prefix = 'et_color_scheme_';
  1022.  
  1023. if ( 'none' !== $color_scheme ) $body_class[] = $color_scheme_prefix . $color_scheme;
  1024.  
  1025. return $body_class;
  1026. }
  1027. add_filter( 'body_class', 'et_customizer_color_scheme_class' );
  1028.  
  1029. function et_load_google_fonts_scripts() {
  1030. wp_enqueue_script( 'et_google_fonts', get_template_directory_uri() . '/epanel/google-fonts/et_google_fonts.js', array( 'jquery' ), '1.0', true );
  1031. }
  1032. add_action( 'customize_controls_print_footer_scripts', 'et_load_google_fonts_scripts' );
  1033.  
  1034. function et_load_google_fonts_styles() {
  1035. wp_enqueue_style( 'et_google_fonts_style', get_template_directory_uri() . '/epanel/google-fonts/et_google_fonts.css', array(), null );
  1036. }
  1037. add_action( 'customize_controls_print_styles', 'et_load_google_fonts_styles' );
  1038.  
  1039. if ( ! function_exists( 'et_divi_post_meta' ) ) :
  1040. function et_divi_post_meta() {
  1041. $postinfo = is_single() ? et_get_option( 'divi_postinfo2' ) : et_get_option( 'divi_postinfo1' );
  1042.  
  1043. if ( $postinfo ) :
  1044. echo '<p class="post-meta">';
  1045. et_postinfo_meta( $postinfo, et_get_option( 'divi_date_format', 'M j, Y' ), esc_html__( '0 comments', 'Divi' ), esc_html__( '1 comment', 'Divi' ), '% ' . esc_html__( 'comments', 'Divi' ) );
  1046. echo '</p>';
  1047. endif;
  1048. }
  1049. endif;
  1050.  
  1051. /**
  1052. * Extract and return the first blockquote from content.
  1053. */
  1054. if ( ! function_exists( 'et_get_blockquote_in_content' ) ) :
  1055. function et_get_blockquote_in_content() {
  1056. global $more;
  1057. $more_default = $more;
  1058. $more = 1;
  1059.  
  1060. remove_filter( 'the_content', 'et_remove_blockquote_from_content' );
  1061.  
  1062. $content = apply_filters( 'the_content', get_the_content() );
  1063.  
  1064. add_filter( 'the_content', 'et_remove_blockquote_from_content' );
  1065.  
  1066. $more = $more_default;
  1067.  
  1068. if ( preg_match( '/<blockquote>(.+?)<\/blockquote>/is', $content, $matches ) ) {
  1069. return $matches[0];
  1070. } else {
  1071. return false;
  1072. }
  1073. }
  1074. endif;
  1075.  
  1076. function et_remove_blockquote_from_content( $content ) {
  1077. if ( 'quote' !== get_post_format() ) {
  1078. return $content;
  1079. }
  1080.  
  1081. $content = preg_replace( '/<blockquote>(.+?)<\/blockquote>/is', '', $content, 1 );
  1082.  
  1083. return $content;
  1084. }
  1085. add_filter( 'the_content', 'et_remove_blockquote_from_content' );
  1086.  
  1087. if ( ! function_exists( 'et_get_link_url' ) ) :
  1088. function et_get_link_url() {
  1089. if ( '' !== ( $link_url = get_post_meta( get_the_ID(), '_format_link_url', true ) ) ) {
  1090. return $link_url;
  1091. }
  1092.  
  1093. $content = get_the_content();
  1094. $has_url = get_url_in_content( $content );
  1095.  
  1096. return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
  1097. }
  1098. endif;
  1099.  
  1100. function et_video_embed_html( $video ) {
  1101. if ( is_single() && 'video' === get_post_format() ) {
  1102. static $post_video_num = 0;
  1103.  
  1104. $post_video_num++;
  1105.  
  1106. // Hide first video in the post content on single video post page
  1107. if ( 1 === $post_video_num ) {
  1108. return '';
  1109. }
  1110. }
  1111.  
  1112. return "<div class='et_post_video'>{$video}</div>";
  1113. }
  1114. add_filter( 'embed_oembed_html', 'et_video_embed_html' );
  1115.  
  1116. /**
  1117. * Removes galleries on single gallery posts, since we display images from all
  1118. * galleries on top of the page
  1119. */
  1120. function et_delete_post_gallery( $content ) {
  1121. if ( is_single() && is_main_query() && has_post_format( 'gallery' ) ) :
  1122. $regex = get_shortcode_regex();
  1123. preg_match_all( "/{$regex}/s", $content, $matches );
  1124.  
  1125. // $matches[2] holds an array of shortcodes names in the post
  1126. foreach ( $matches[2] as $key => $shortcode_match ) {
  1127. if ( 'gallery' === $shortcode_match )
  1128. $content = str_replace( $matches[0][$key], '', $content );
  1129. }
  1130. endif;
  1131.  
  1132. return $content;
  1133. }
  1134. add_filter( 'the_content', 'et_delete_post_gallery' );
  1135.  
  1136. /*
  1137. * Removes the first video shortcode from content on single pages since it is displayed
  1138. * at the top of the page. This will also remove the video shortcode url from archive pages content
  1139. */
  1140. function et_delete_post_video( $content ) {
  1141. if ( has_post_format( 'video' ) ) :
  1142. $regex = get_shortcode_regex();
  1143. preg_match_all( "/{$regex}/s", $content, $matches );
  1144.  
  1145. // $matches[2] holds an array of shortcodes names in the post
  1146. foreach ( $matches[2] as $key => $shortcode_match ) {
  1147. if ( 'video' === $shortcode_match ) {
  1148. $content = str_replace( $matches[0][$key], '', $content );
  1149. if ( is_single() && is_main_query() ) {
  1150. break;
  1151. }
  1152. }
  1153. }
  1154. endif;
  1155.  
  1156. return $content;
  1157. }
  1158.  
  1159. if ( ! function_exists( 'et_gallery_images' ) ) :
  1160. function et_gallery_images() {
  1161. $output = $images_ids = '';
  1162.  
  1163. if ( function_exists( 'get_post_galleries' ) ) {
  1164. $galleries = get_post_galleries( get_the_ID(), false );
  1165.  
  1166. if ( empty( $galleries ) ) return false;
  1167.  
  1168. foreach ( $galleries as $gallery ) {
  1169. // Grabs all attachments ids from one or multiple galleries in the post
  1170. $images_ids .= ( '' !== $images_ids ? ',' : '' ) . $gallery['ids'];
  1171. }
  1172.  
  1173. $attachments_ids = explode( ',', $images_ids );
  1174. // Removes duplicate attachments ids
  1175. $attachments_ids = array_unique( $attachments_ids );
  1176. } else {
  1177. $pattern = get_shortcode_regex();
  1178. preg_match( "/$pattern/s", get_the_content(), $match );
  1179. $atts = shortcode_parse_atts( $match[3] );
  1180.  
  1181. if ( isset( $atts['ids'] ) )
  1182. $attachments_ids = explode( ',', $atts['ids'] );
  1183. else
  1184. return false;
  1185. }
  1186.  
  1187. $slides = '';
  1188.  
  1189. foreach ( $attachments_ids as $attachment_id ) {
  1190. $attachment_attributes = wp_get_attachment_image_src( $attachment_id, 'et-pb-post-main-image-fullwidth' );
  1191. $attachment_image = ! is_single() ? $attachment_attributes[0] : wp_get_attachment_image( $attachment_id, 'et-pb-portfolio-image' );
  1192.  
  1193. if ( ! is_single() ) {
  1194. $slides .= sprintf(
  1195. '<div class="et_pb_slide" style="background: url(%1$s);"></div>',
  1196. esc_attr( $attachment_image )
  1197. );
  1198. } else {
  1199. $full_image = wp_get_attachment_image_src( $attachment_id, 'full' );
  1200. $full_image_url = $full_image[0];
  1201. $attachment = get_post( $attachment_id );
  1202.  
  1203. $slides .= sprintf(
  1204. '<li class="et_gallery_item">
  1205. <a href="%1$s" title="%3$s">
  1206. <span class="et_portfolio_image">
  1207. %2$s
  1208. <span class="et_overlay"></span>
  1209. </span>
  1210. </a>
  1211. </li>',
  1212. esc_url( $full_image_url ),
  1213. $attachment_image,
  1214. esc_attr( $attachment->post_title )
  1215. );
  1216. }
  1217. }
  1218.  
  1219. if ( ! is_single() ) {
  1220. $output =
  1221. '<div class="et_pb_slider et_pb_slider_fullwidth_off">
  1222. <div class="et_pb_slides">
  1223. %1$s
  1224. </div>
  1225. </div>';
  1226. } else {
  1227. $output =
  1228. '<ul class="et_post_gallery clearfix">
  1229. %1$s
  1230. </ul>';
  1231. }
  1232.  
  1233. printf( $output, $slides );
  1234. }
  1235. endif;
  1236.  
  1237. if ( ! function_exists( 'et_get_first_video' ) ) :
  1238. function et_get_first_video() {
  1239. $first_video = '';
  1240. $custom_fields = get_post_custom();
  1241. $video_width = (int) apply_filters( 'et_blog_video_width', 1080 );
  1242. $video_height = (int) apply_filters( 'et_blog_video_height', 630 );
  1243.  
  1244. foreach ( $custom_fields as $key => $custom_field ) {
  1245. if ( 0 !== strpos( $key, '_oembed_' ) ) {
  1246. continue;
  1247. }
  1248.  
  1249. $first_video = $custom_field[0];
  1250.  
  1251. $first_video = preg_replace( '/<embed /', '<embed wmode="transparent" ', $first_video );
  1252. $first_video = preg_replace( '/<\/object>/','<param name="wmode" value="transparent" /></object>', $first_video );
  1253.  
  1254. $first_video = preg_replace( "/width=\"[0-9]*\"/", "width={$video_width}", $first_video );
  1255. $first_video = preg_replace( "/height=\"[0-9]*\"/", "height={$video_height}", $first_video );
  1256.  
  1257. break;
  1258. }
  1259.  
  1260. if ( '' === $first_video && has_shortcode( get_the_content(), 'video' ) ) {
  1261. $regex = get_shortcode_regex();
  1262. preg_match( "/{$regex}/s", get_the_content(), $match );
  1263.  
  1264. $first_video = preg_replace( "/width=\"[0-9]*\"/", "width=\"{$video_width}\"", $match[0] );
  1265. $first_video = preg_replace( "/height=\"[0-9]*\"/", "height=\"{$video_height}\"", $first_video );
  1266.  
  1267. add_filter( 'the_content', 'et_delete_post_video' );
  1268.  
  1269. $first_video = do_shortcode( et_pb_fix_shortcodes( $first_video ) );
  1270. }
  1271.  
  1272. return ( '' !== $first_video ) ? $first_video : false;
  1273. }
  1274. endif;
  1275.  
  1276. function et_divi_post_admin_scripts_styles( $hook ) {
  1277. global $typenow;
  1278.  
  1279. if ( ! in_array( $hook, array( 'post-new.php', 'post.php' ) ) ) return;
  1280.  
  1281. if ( ! isset( $typenow ) ) return;
  1282.  
  1283. if ( in_array( $typenow, array( 'post' ) ) ) {
  1284. wp_enqueue_style( 'wp-color-picker' );
  1285. wp_enqueue_script( 'wp-color-picker' );
  1286. wp_enqueue_script( 'et-admin-post-script', get_template_directory_uri() . '/js/admin_post_settings.js', array( 'jquery' ) );
  1287. }
  1288. }
  1289. add_action( 'admin_enqueue_scripts', 'et_divi_post_admin_scripts_styles' );
  1290.  
  1291. function et_password_form() {
  1292. $pwbox_id = rand();
  1293.  
  1294. $form_output = sprintf(
  1295. '<div class="et_password_protected_form">
  1296. <h1>%1$s</h1>
  1297. <p>%2$s:</p>
  1298. <form action="%3$s" method="post">
  1299. <p><label for="%4$s">%5$s: </label><input name="post_password" id="%4$s" type="password" size="20" maxlength="20" /></p>
  1300. <p><button type="submit" class="et_submit_button">%6$s</button></p>
  1301. </form
  1302. </div>',
  1303. esc_html__( 'Password Protected', 'Divi' ),
  1304. esc_html__( 'To view this protected post, enter the password below', 'Divi' ),
  1305. esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ),
  1306. esc_attr( 'pwbox-' . $pwbox_id ),
  1307. esc_html__( 'Password', 'Divi' ),
  1308. esc_html__( 'Submit', 'Divi' )
  1309. );
  1310.  
  1311. $output = sprintf(
  1312. '<div class="et_pb_section et_section_regular">
  1313. <div class="et_pb_row">
  1314. <div class="et_pb_column et_pb_column_4_4">
  1315. %1$s
  1316. </div>
  1317. </div>
  1318. </div>',
  1319. $form_output
  1320. );
  1321.  
  1322. return $output;
  1323. }
  1324. add_filter( 'the_password_form', 'et_password_form' );
  1325.  
  1326. function et_add_wp_version( $classes ) {
  1327. global $wp_version;
  1328.  
  1329. // add 'et-wp-pre-3_8' class if the current WordPress version is less than 3.8
  1330. if ( version_compare( $wp_version, '3.7.2', '<=' ) ) {
  1331. if ( 'body_class' === current_filter() )
  1332. $classes[] = 'et-wp-pre-3_8';
  1333. else
  1334. $classes = 'et-wp-pre-3_8';
  1335. } else {
  1336. if ( 'admin_body_class' === current_filter() )
  1337. $classes = 'et-wp-after-3_8';
  1338. }
  1339.  
  1340. return $classes;
  1341. }
  1342. add_filter( 'body_class', 'et_add_wp_version' );
  1343. add_filter( 'admin_body_class', 'et_add_wp_version' );
  1344.  
  1345. function et_layout_body_class( $classes ) {
  1346. if ( true === et_get_option( 'vertical_nav', false ) ) {
  1347. $classes[] = 'et_vertical_nav';
  1348. } else if ( 'on' === et_get_option( 'divi_fixed_nav', 'on' ) ) {
  1349. $classes[] = 'et_fixed_nav';
  1350. }
  1351.  
  1352. if ( true === et_get_option( 'boxed_layout', false ) ) {
  1353. $classes[] = 'et_boxed_layout';
  1354. }
  1355.  
  1356. if ( true === et_get_option( 'cover_background', true ) ) {
  1357. $classes[] = 'et_cover_background';
  1358. }
  1359.  
  1360. $et_secondary_nav_items = et_divi_get_top_nav_items();
  1361.  
  1362. if ( $et_secondary_nav_items->top_info_defined ) {
  1363. $classes[] = 'et_secondary_nav_enabled';
  1364. }
  1365.  
  1366. if ( $et_secondary_nav_items->two_info_panels ) {
  1367. $classes[] = 'et_secondary_nav_two_panels';
  1368. }
  1369.  
  1370. if ( $et_secondary_nav_items->secondary_nav && ! ( $et_secondary_nav_items->contact_info_defined || $et_secondary_nav_items->show_header_social_icons ) ) {
  1371. $classes[] = 'et_secondary_nav_only_menu';
  1372. }
  1373.  
  1374. if ( 'left' !== ( $header_style = et_get_option( 'header_style', 'left' ) ) ) {
  1375. $classes[] = esc_attr( "et_header_style_{$header_style}" );
  1376. }
  1377.  
  1378. if ( ( is_page() || is_singular( 'project' ) ) && 'on' == get_post_meta( get_the_ID(), '_et_pb_side_nav', true ) && et_pb_is_pagebuilder_used( get_the_ID() ) ) {
  1379. $classes[] = 'et_pb_side_nav_page';
  1380. }
  1381.  
  1382. if ( stristr( $_SERVER['HTTP_USER_AGENT'],"mac") ) {
  1383. $classes[] = 'osx';
  1384. } elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"linux") ) {
  1385. $classes[] = 'linux';
  1386. } elseif ( stristr( $_SERVER['HTTP_USER_AGENT'],"windows") ) {
  1387. $classes[] = 'windows';
  1388. }
  1389.  
  1390. return $classes;
  1391. }
  1392. add_filter( 'body_class', 'et_layout_body_class' );
  1393.  
  1394. if ( ! function_exists( 'et_show_cart_total' ) ) {
  1395. function et_show_cart_total( $args = array() ) {
  1396. if ( ! class_exists( 'woocommerce' ) ) {
  1397. return;
  1398. }
  1399.  
  1400. $defaults = array(
  1401. 'no_text' => false,
  1402. );
  1403.  
  1404. $args = wp_parse_args( $args, $defaults );
  1405.  
  1406. printf(
  1407. '<a href="%1$s" class="et-cart-info">
  1408. <span>%2$s</span>
  1409. </a>',
  1410. esc_url( WC()->cart->get_cart_url() ),
  1411. ( ! $args['no_text']
  1412. ? sprintf(
  1413. __( '%1$s %2$s', 'Divi' ),
  1414. esc_html( WC()->cart->get_cart_contents_count() ),
  1415. ( 1 === WC()->cart->get_cart_contents_count() ? __( 'Item', 'Divi' ) : __( 'Items', 'Divi' ) )
  1416. )
  1417. : ''
  1418. )
  1419. );
  1420. }
  1421. }
  1422.  
  1423. if ( ! function_exists( 'et_divi_get_top_nav_items' ) ) {
  1424. function et_divi_get_top_nav_items() {
  1425. $items = new stdClass;
  1426.  
  1427. $items->phone_number = et_get_option( 'phone_number' );
  1428.  
  1429. $items->email = et_get_option( 'header_email' );
  1430.  
  1431. $items->contact_info_defined = $items->phone_number || $items->email;
  1432.  
  1433. $items->show_header_social_icons = et_get_option( 'show_header_social_icons', false );
  1434.  
  1435. $items->secondary_nav = wp_nav_menu( array(
  1436. 'theme_location' => 'secondary-menu',
  1437. 'container' => '',
  1438. 'fallback_cb' => '',
  1439. 'menu_id' => 'et-secondary-nav',
  1440. 'echo' => false,
  1441. ) );
  1442.  
  1443. $items->top_info_defined = $items->contact_info_defined || $items->show_header_social_icons || $items->secondary_nav;
  1444.  
  1445. $items->two_info_panels = $items->contact_info_defined && ( $items->show_header_social_icons || $items->secondary_nav );
  1446.  
  1447. return $items;
  1448. }
  1449. }
  1450.  
  1451. function et_divi_activate_features(){
  1452. /* activate shortcodes */
  1453. require_once( get_template_directory() . '/epanel/shortcodes/shortcodes.php' );
  1454. }
  1455. add_action( 'init', 'et_divi_activate_features' );
  1456.  
  1457. require_once( get_template_directory() . '/et-pagebuilder/et-pagebuilder.php' );
  1458.  
  1459. function et_divi_sidebar_class( $classes ) {
  1460. if ( ( is_page() || is_singular( 'project' ) ) && et_pb_is_pagebuilder_used( get_the_ID() ) )
  1461. $classes[] = 'et_pb_pagebuilder_layout';
  1462.  
  1463. if ( is_single() || is_page() || ( class_exists( 'woocommerce' ) && is_product() ) )
  1464. $page_layout = '' !== ( $layout = get_post_meta( get_the_ID(), '_et_pb_page_layout', true ) )
  1465. ? $layout
  1466. : 'et_right_sidebar';
  1467.  
  1468. if ( class_exists( 'woocommerce' ) && ( is_shop() || is_product() || is_product_category() || is_product_tag() ) ) {
  1469. if ( is_shop() || is_tax() )
  1470. $classes[] = et_get_option( 'divi_shop_page_sidebar', 'et_right_sidebar' );
  1471. if ( is_product() )
  1472. $classes[] = $page_layout;
  1473. }
  1474.  
  1475. else if ( is_archive() || is_home() || is_search() || is_404() ) {
  1476. $classes[] = 'et_right_sidebar';
  1477. }
  1478.  
  1479. else if ( is_singular( 'project' ) ) {
  1480. if ( 'et_full_width_page' === $page_layout )
  1481. $page_layout = 'et_right_sidebar et_full_width_portfolio_page';
  1482.  
  1483. $classes[] = $page_layout;
  1484. }
  1485.  
  1486. else if ( is_single() || is_page() ) {
  1487. $classes[] = $page_layout;
  1488. }
  1489.  
  1490. return $classes;
  1491. }
  1492. add_filter( 'body_class', 'et_divi_sidebar_class' );
  1493.  
  1494. function et_modify_shop_page_columns_num( $columns_num ) {
  1495. if ( class_exists( 'woocommerce' ) && is_shop() ) {
  1496. $columns_num = 'et_full_width_page' !== et_get_option( 'divi_shop_page_sidebar', 'et_right_sidebar' )
  1497. ? 3
  1498. : 4;
  1499. }
  1500.  
  1501. return $columns_num;
  1502. }
  1503. add_filter( 'loop_shop_columns', 'et_modify_shop_page_columns_num' );
  1504.  
  1505. // WooCommerce
  1506.  
  1507. global $pagenow;
  1508. if ( is_admin() && isset( $_GET['activated'] ) && $pagenow == 'themes.php' )
  1509. add_action( 'init', 'et_divi_woocommerce_image_dimensions', 1 );
  1510.  
  1511. /**
  1512. * Default values for WooCommerce images changed in version 1.3
  1513. * Checks if WooCommerce image dimensions have been updated already.
  1514. */
  1515. function et_divi_check_woocommerce_images() {
  1516. if ( 'checked' === et_get_option( 'divi_1_3_images' ) ) return;
  1517.  
  1518. et_divi_woocommerce_image_dimensions();
  1519. et_update_option( 'divi_1_3_images', 'checked' );
  1520. }
  1521. add_action( 'admin_init', 'et_divi_check_woocommerce_images' );
  1522.  
  1523. function et_divi_woocommerce_image_dimensions() {
  1524. $catalog = array(
  1525. 'width' => '400',
  1526. 'height' => '400',
  1527. 'crop' => 1,
  1528. );
  1529.  
  1530. $single = array(
  1531. 'width' => '510',
  1532. 'height' => '9999',
  1533. 'crop' => 0,
  1534. );
  1535.  
  1536. $thumbnail = array(
  1537. 'width' => '157',
  1538. 'height' => '157',
  1539. 'crop' => 1,
  1540. );
  1541.  
  1542. update_option( 'shop_catalog_image_size', $catalog );
  1543. update_option( 'shop_single_image_size', $single );
  1544. update_option( 'shop_thumbnail_image_size', $thumbnail );
  1545. }
  1546.  
  1547. function woocommerce_template_loop_product_thumbnail() {
  1548. printf( '<span class="et_shop_image">%1$s<span class="et_overlay"></span></span>',
  1549. woocommerce_get_product_thumbnail()
  1550. );
  1551. }
  1552.  
  1553. function et_review_gravatar_size( $size ) {
  1554. return '80';
  1555. }
  1556. add_filter( 'woocommerce_review_gravatar_size', 'et_review_gravatar_size' );
  1557.  
  1558.  
  1559. function et_divi_output_content_wrapper() {
  1560. echo '
  1561. <div id="main-content">
  1562. <div class="container">
  1563. <div id="content-area" class="clearfix">
  1564. <div id="left-area">';
  1565. }
  1566.  
  1567. function et_divi_output_content_wrapper_end() {
  1568. echo '</div> <!-- #left-area -->';
  1569.  
  1570. if (
  1571. ( is_product() && 'et_full_width_page' !== get_post_meta( get_the_ID(), '_et_pb_page_layout', true ) )
  1572. ||
  1573. ( ( is_shop() || is_product_category() || is_product_tag() ) && 'et_full_width_page' !== et_get_option( 'divi_shop_page_sidebar', 'et_right_sidebar' ) )
  1574. ) {
  1575. woocommerce_get_sidebar();
  1576. }
  1577.  
  1578. echo '
  1579. </div> <!-- #content-area -->
  1580. </div> <!-- .container -->
  1581. </div> <!-- #main-content -->';
  1582. }
  1583.  
  1584. function et_aweber_authorization_option() {
  1585. wp_enqueue_script( 'divi-advanced-options', get_template_directory_uri() . '/js/advanced_options.js', array( 'jquery' ), '1.0', true );
  1586. wp_localize_script( 'divi-advanced-options', 'et_advanced_options', array(
  1587. 'et_load_nonce' => wp_create_nonce( 'et_load_nonce' ),
  1588. 'aweber_connecting' => __( 'Connecting...', 'Divi' ),
  1589. 'aweber_failed' => __( 'Connection failed', 'Divi' ),
  1590. 'aweber_remove_connection' => __( 'Removing connection...', 'Divi' ),
  1591. 'aweber_done' => __( 'Done', 'Divi' ),
  1592. ) );
  1593. wp_enqueue_style( 'divi-advanced-options', get_template_directory_uri() . '/css/advanced_options.css' );
  1594.  
  1595. $app_id = 'b17f3351';
  1596.  
  1597. $aweber_auth_endpoint = 'https://auth.aweber.com/1.0/oauth/authorize_app/' . $app_id;
  1598.  
  1599. $hide_style = ' style="display: none;"';
  1600.  
  1601. $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 );
  1602.  
  1603. $output = sprintf(
  1604. '<div id="et_aweber_connection">
  1605. <ul id="et_aweber_authorization"%4$s>
  1606. <li>%1$s</li>
  1607. <li>
  1608. <p>%2$s</p>
  1609. <p><textarea id="et_aweber_authentication_code" name="et_aweber_authentication_code"></textarea></p>
  1610.  
  1611. <p><button class="et_make_connection button button-primary button-large">%3$s</button></p>
  1612. </li>
  1613. </ul>
  1614.  
  1615. <div id="et_aweber_remove_connection"%5$s>
  1616. <p>%6$s</p>
  1617. <p><button class="et_remove_connection button button-primary button-large">%7$s</button></p>
  1618. </div>
  1619. </div>',
  1620. sprintf( __( 'Step 1: <a href="%1$s" target="_blank">Generate authorization code</a>', 'Divi' ), esc_url( $aweber_auth_endpoint ) ),
  1621. __( 'Step 2: Paste in the authorization code and click "Make a connection" button: ', 'Divi' ),
  1622. __( 'Make a connection', 'Divi' ),
  1623. ( $aweber_connection_established ? $hide_style : '' ),
  1624. ( ! $aweber_connection_established ? $hide_style : '' ),
  1625. __( 'Aweber is set up properly. You can remove connection here if you wish.', 'Divi' ),
  1626. __( 'Remove the connection', 'Divi' )
  1627. );
  1628.  
  1629. echo $output;
  1630. }
  1631.  
  1632. function et_aweber_submit_authorization_code() {
  1633. if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) {
  1634. die( __( 'Nonce failed.', 'Divi' ) );
  1635. }
  1636.  
  1637. $et_authorization_code = $_POST['et_authorization_code'];
  1638.  
  1639. if ( '' === $et_authorization_code ) {
  1640. die( __( 'Authorization code is empty.', 'Divi' ) );
  1641. }
  1642.  
  1643. if ( ! class_exists( 'AWeberAPI' ) ) {
  1644. require_once( get_template_directory() . '/includes/subscription/aweber/aweber_api.php' );
  1645. }
  1646.  
  1647. try {
  1648. $auth = AWeberAPI::getDataFromAweberID( $et_authorization_code );
  1649.  
  1650. if ( ! ( is_array( $auth ) && 4 === count( $auth ) ) ) {
  1651. die ( __( 'Authorization code is invalid. Try regenerating it and paste in the new code.', 'Divi' ) );
  1652. }
  1653.  
  1654. list( $consumer_key, $consumer_secret, $access_key, $access_secret ) = $auth;
  1655.  
  1656. et_update_option( 'divi_aweber_consumer_key', $consumer_key );
  1657. et_update_option( 'divi_aweber_consumer_secret', $consumer_secret );
  1658. et_update_option( 'divi_aweber_access_key', $access_key );
  1659. et_update_option( 'divi_aweber_access_secret', $access_secret );
  1660.  
  1661. die( 'success' );
  1662. } catch ( AWeberAPIException $exc ) {
  1663. printf(
  1664. '<p>%4$s.</p>
  1665. <ul>
  1666. <li>%5$s: %1$s</li>
  1667. <li>%6$s: %2$s</li>
  1668. <li>%7$s: %3$s</li>
  1669. </ul>',
  1670. esc_html( $exc->type ),
  1671. esc_html( $exc->message ),
  1672. esc_html( $exc->documentation_url ),
  1673. esc_html__( 'Aweber API Exception', 'Divi' ),
  1674. esc_html__( 'Type', 'Divi' ),
  1675. esc_html__( 'Message', 'Divi' ),
  1676. esc_html__( 'Documentation', 'Divi' )
  1677. );
  1678. }
  1679.  
  1680. die();
  1681. }
  1682. add_action( 'wp_ajax_et_aweber_submit_authorization_code', 'et_aweber_submit_authorization_code' );
  1683.  
  1684. function et_aweber_remove_connection() {
  1685. if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) {
  1686. die( __( 'Nonce failed', 'Divi' ) );
  1687. }
  1688.  
  1689. et_delete_option( 'divi_aweber_consumer_key' );
  1690. et_delete_option( 'divi_aweber_consumer_secret' );
  1691. et_delete_option( 'divi_aweber_access_key' );
  1692. et_delete_option( 'divi_aweber_access_secret' );
  1693.  
  1694. die( 'success' );
  1695. }
  1696. add_action( 'wp_ajax_et_aweber_remove_connection', 'et_aweber_remove_connection' );
  1697.  
  1698. if ( ! function_exists( 'et_pb_get_audio_player' ) ){
  1699. function et_pb_get_audio_player(){
  1700. $output = sprintf(
  1701. '<div class="et_audio_container">
  1702. %1$s
  1703. </div> <!-- .et_audio_container -->',
  1704. do_shortcode( '[audio]' )
  1705. );
  1706.  
  1707. return $output;
  1708. }
  1709. }
  1710.  
  1711. if ( ! function_exists( 'et_divi_get_post_text_color' ) ) {
  1712. function et_divi_get_post_text_color() {
  1713. $text_color_class = '';
  1714.  
  1715. $post_format = get_post_format();
  1716.  
  1717. if ( in_array( $post_format, array( 'audio', 'link', 'quote' ) ) ) {
  1718. $text_color_class = ( $text_color = get_post_meta( get_the_ID(), '_et_post_bg_layout', true ) ) ? $text_color : 'light';
  1719. $text_color_class = ' et_pb_text_color_' . $text_color_class;
  1720. }
  1721.  
  1722. return $text_color_class;
  1723. }
  1724. }
  1725.  
  1726. if ( ! function_exists( 'et_divi_get_post_bg_inline_style' ) ) {
  1727. function et_divi_get_post_bg_inline_style() {
  1728. $inline_style = '';
  1729.  
  1730. $post_id = get_the_ID();
  1731.  
  1732. $post_use_bg_color = get_post_meta( $post_id, '_et_post_use_bg_color', true )
  1733. ? true
  1734. : false;
  1735. $post_bg_color = ( $bg_color = get_post_meta( $post_id, '_et_post_bg_color', true ) ) && '' !== $bg_color
  1736. ? $bg_color
  1737. : '#ffffff';
  1738.  
  1739. if ( $post_use_bg_color ) {
  1740. $inline_style = sprintf( ' style="background-color: %1$s;"', esc_html( $post_bg_color ) );
  1741. }
  1742.  
  1743. return $inline_style;
  1744. }
  1745. }
  1746.  
  1747. /*
  1748. * Displays post audio, quote and link post formats content
  1749. */
  1750. if ( ! function_exists( 'et_divi_post_format_content' ) ){
  1751. function et_divi_post_format_content(){
  1752. $post_format = get_post_format();
  1753.  
  1754. $text_color_class = et_divi_get_post_text_color();
  1755.  
  1756. $inline_style = et_divi_get_post_bg_inline_style();
  1757.  
  1758. switch ( $post_format ) {
  1759. case 'audio' :
  1760. printf(
  1761. '<div class="et_audio_content%4$s"%5$s>
  1762. <h2><a href="%3$s">%1$s</a></h2>
  1763. %2$s
  1764. </div> <!-- .et_audio_content -->',
  1765. get_the_title(),
  1766. et_pb_get_audio_player(),
  1767. esc_url( get_permalink() ),
  1768. esc_attr( $text_color_class ),
  1769. $inline_style
  1770. );
  1771.  
  1772. break;
  1773. case 'quote' :
  1774. printf(
  1775. '<div class="et_quote_content%4$s"%5$s>
  1776. %1$s
  1777. <a href="%2$s" class="et_quote_main_link">%3$s</a>
  1778. </div> <!-- .et_quote_content -->',
  1779. et_get_blockquote_in_content(),
  1780. esc_url( get_permalink() ),
  1781. __( 'Read more', 'Divi' ),
  1782. esc_attr( $text_color_class ),
  1783. $inline_style
  1784. );
  1785.  
  1786. break;
  1787. case 'link' :
  1788. printf(
  1789. '<div class="et_link_content%5$s"%6$s>
  1790. <h2><a href="%2$s">%1$s</a></h2>
  1791. <a href="%3$s" class="et_link_main_url">%4$s</a>
  1792. </div> <!-- .et_link_content -->',
  1793. get_the_title(),
  1794. esc_url( get_permalink() ),
  1795. esc_url( et_get_link_url() ),
  1796. esc_html( et_get_link_url() ),
  1797. esc_attr( $text_color_class ),
  1798. $inline_style
  1799. );
  1800.  
  1801. break;
  1802. }
  1803. }
  1804. }
  1805.  
  1806. if ( ! function_exists( 'et_pb_check_oembed_provider' ) ) {
  1807. function et_pb_check_oembed_provider( $url ) {
  1808. require_once( ABSPATH . WPINC . '/class-oembed.php' );
  1809. $oembed = _wp_oembed_get_object();
  1810. return $oembed->get_provider( esc_url( $url ), array( 'discover' => false ) );
  1811. }
  1812. }
  1813.  
  1814. // Shortcodes
  1815.  
  1816. if ( ! function_exists( 'et_pb_fix_shortcodes' ) ){
  1817. function et_pb_fix_shortcodes( $content ){
  1818. $replace_tags_from_to = array (
  1819. '<p>[' => '[',
  1820. ']</p>' => ']',
  1821. ']<br />' => ']',
  1822. "<br />\n[" => '[',
  1823. );
  1824.  
  1825. return strtr( $content, $replace_tags_from_to );
  1826. }
  1827. }
  1828.  
  1829. add_shortcode( 'et_pb_slider', 'et_pb_slider' );
  1830. add_shortcode( 'et_pb_fullwidth_slider', 'et_pb_slider' );
  1831. function et_pb_slider( $atts, $content = '', $function_name ) {
  1832. extract( shortcode_atts( array(
  1833. 'module_id' => '',
  1834. 'module_class' => '',
  1835. 'show_arrows' => 'on',
  1836. 'show_pagination' => 'on',
  1837. 'parallax' => 'off',
  1838. 'parallax_method' => 'off',
  1839. 'auto' => 'off',
  1840. 'auto_speed' => '7000',
  1841. ), $atts
  1842. ) );
  1843.  
  1844. global $et_pb_slider_has_video, $et_pb_slider_parallax, $et_pb_slider_parallax_method;
  1845.  
  1846. $et_pb_slider_has_video = false;
  1847.  
  1848. $et_pb_slider_parallax = $parallax;
  1849.  
  1850. $et_pb_slider_parallax_method = $parallax_method;
  1851.  
  1852. $fullwidth = 'et_pb_fullwidth_slider' === $function_name ? 'on' : 'off';
  1853.  
  1854. $class = '';
  1855. $class .= 'off' === $fullwidth ? ' et_pb_slider_fullwidth_off' : '';
  1856. $class .= 'off' === $show_arrows ? ' et_pb_slider_no_arrows' : '';
  1857. $class .= 'off' === $show_pagination ? ' et_pb_slider_no_pagination' : '';
  1858. $class .= 'on' === $parallax ? ' et_pb_slider_parallax' : '';
  1859. $class .= 'on' === $auto ? ' et_slider_auto et_slider_speed_' . esc_attr( $auto_speed ) : '';
  1860.  
  1861. $content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  1862.  
  1863. $output = sprintf(
  1864. '<div%4$s class="et_pb_slider%1$s%3$s%5$s">
  1865. <div class="et_pb_slides">
  1866. %2$s
  1867. </div> <!-- .et_pb_slides -->
  1868. </div> <!-- .et_pb_slider -->
  1869. ',
  1870. $class,
  1871. $content,
  1872. ( $et_pb_slider_has_video ? ' et_pb_preload' : '' ),
  1873. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  1874. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  1875. );
  1876.  
  1877. return $output;
  1878. }
  1879.  
  1880. add_shortcode( 'et_pb_slide', 'et_pb_slide' );
  1881. function et_pb_slide( $atts, $content = '' ) {
  1882. extract( shortcode_atts( array(
  1883. 'alignment' => 'center',
  1884. 'heading' => '',
  1885. 'button_text' => '',
  1886. 'button_link' => '#',
  1887. 'background_color' => '',
  1888. 'background_image' => '',
  1889. 'image' => '',
  1890. 'image_alt' => '',
  1891. 'background_layout' => 'dark',
  1892. 'video_bg_webm' => '',
  1893. 'video_bg_mp4' => '',
  1894. 'video_bg_width' => '',
  1895. 'video_bg_height' => '',
  1896. 'video_url' => '',
  1897. 'allow_player_pause' => 'off',
  1898. ), $atts
  1899. ) );
  1900.  
  1901. global $et_pb_slider_has_video, $et_pb_slider_parallax, $et_pb_slider_parallax_method;
  1902.  
  1903. $background_video = '';
  1904.  
  1905. $first_video = false;
  1906.  
  1907. if ( '' !== $video_bg_mp4 || '' !== $video_bg_webm ) {
  1908. if ( ! $et_pb_slider_has_video )
  1909. $first_video = true;
  1910.  
  1911. $background_video = sprintf(
  1912. '<div class="et_pb_section_video_bg%2$s%3$s">
  1913. %1$s
  1914. </div>',
  1915. do_shortcode( sprintf( '
  1916. <video loop="loop" autoplay="autoplay"%3$s%4$s>
  1917. %1$s
  1918. %2$s
  1919. </video>',
  1920. ( '' !== $video_bg_mp4 ? sprintf( '<source type="video/mp4" src="%s" />', esc_attr( $video_bg_mp4 ) ) : '' ),
  1921. ( '' !== $video_bg_webm ? sprintf( '<source type="video/webm" src="%s" />', esc_attr( $video_bg_webm ) ) : '' ),
  1922. ( '' !== $video_bg_width ? sprintf( ' width="%s"', esc_attr( $video_bg_width ) ) : '' ),
  1923. ( '' !== $video_bg_height ? sprintf( ' height="%s"', esc_attr( $video_bg_height ) ) : '' ),
  1924. ( '' !== $background_image ? sprintf( ' poster="%s"', esc_attr( $background_image ) ) : '' )
  1925. ) ),
  1926. ( $first_video ? ' et_pb_first_video' : '' ),
  1927. ( 'on' === $allow_player_pause ? ' et_pb_allow_player_pause' : '' )
  1928. );
  1929.  
  1930. $et_pb_slider_has_video = true;
  1931.  
  1932. wp_enqueue_style( 'wp-mediaelement' );
  1933. wp_enqueue_script( 'wp-mediaelement' );
  1934. }
  1935.  
  1936. if ( '' !== $heading ) {
  1937. if ( '#' !== $button_link ) {
  1938. $heading = sprintf( '<a href="%1$s">%2$s</a>',
  1939. esc_url( $button_link ),
  1940. $heading
  1941. );
  1942. }
  1943.  
  1944. $heading = '<h2>' . $heading . '</h2>';
  1945. }
  1946.  
  1947. $button = '';
  1948. if ( '' !== $button_text )
  1949. $button = sprintf( '<a href="%1$s" class="et_pb_more_button">%2$s</a>',
  1950. esc_attr( $button_link ),
  1951. esc_html( $button_text )
  1952. );
  1953.  
  1954. $style = $class = '';
  1955.  
  1956. if ( '' !== $background_color )
  1957. $style .= sprintf( 'background-color:%s;',
  1958. esc_attr( $background_color )
  1959. );
  1960.  
  1961. if ( '' !== $background_image && 'on' !== $et_pb_slider_parallax )
  1962. $style .= sprintf( 'background-image:url(%s);',
  1963. esc_attr( $background_image )
  1964. );
  1965.  
  1966. $style = '' !== $style ? " style='{$style}'" : '';
  1967.  
  1968. $image = '' !== $image
  1969. ? sprintf( '<div class="et_pb_slide_image"><img src="%1$s" alt="%2$s" /></div>',
  1970. esc_attr( $image ),
  1971. esc_attr( $image_alt )
  1972. )
  1973. : '';
  1974.  
  1975. if ( '' !== $video_url ) {
  1976. global $wp_embed;
  1977.  
  1978. $video_embed = apply_filters( 'the_content', $wp_embed->shortcode( '', esc_url( $video_url ) ) );
  1979.  
  1980. $video_embed = preg_replace('/<embed /','<embed wmode="transparent" ',$video_embed);
  1981. $video_embed = preg_replace('/<\/object>/','<param name="wmode" value="transparent" /></object>',$video_embed);
  1982.  
  1983. $image = sprintf( '<div class="et_pb_slide_video">%1$s</div>',
  1984. $video_embed
  1985. );
  1986. }
  1987.  
  1988. if ( '' !== $image ) $class = ' et_pb_slide_with_image';
  1989.  
  1990. if ( '' !== $video_url ) $class .= ' et_pb_slide_with_video';
  1991.  
  1992. $class .= " et_pb_bg_layout_{$background_layout}";
  1993.  
  1994. if ( 'bottom' !== $alignment ) {
  1995. $class .= " et_pb_media_alignment_{$alignment}";
  1996. }
  1997.  
  1998. $output = sprintf(
  1999. '<div class="et_pb_slide%6$s"%4$s>
  2000. %8$s
  2001. <div class="et_pb_container clearfix">
  2002. %5$s
  2003. <div class="et_pb_slide_description">
  2004. %1$s
  2005. <div class="et_pb_slide_content">%2$s</div>
  2006. %3$s
  2007. </div> <!-- .et_pb_slide_description -->
  2008. </div> <!-- .et_pb_container -->
  2009. %7$s
  2010. </div> <!-- .et_pb_slide -->
  2011. ',
  2012. $heading,
  2013. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2014. $button,
  2015. $style,
  2016. $image,
  2017. esc_attr( $class ),
  2018. ( '' !== $background_video ? $background_video : '' ),
  2019. ( '' !== $background_image && 'on' === $et_pb_slider_parallax ? sprintf( '<div class="et_parallax_bg%2$s" style="background-image: url(%1$s);"></div>', esc_attr( $background_image ), ( 'off' === $et_pb_slider_parallax_method ? ' et_pb_parallax_css' : '' ) ) : '' )
  2020. );
  2021.  
  2022. return $output;
  2023. }
  2024.  
  2025. add_shortcode( 'et_pb_section', 'et_pb_section' );
  2026. function et_pb_section( $atts, $content = '' ) {
  2027. extract( shortcode_atts( array(
  2028. 'module_id' => '',
  2029. 'module_class' => '',
  2030. 'background_image' => '',
  2031. 'background_color' => '',
  2032. 'background_video_mp4' => '',
  2033. 'background_video_webm' => '',
  2034. 'background_video_width' => '',
  2035. 'background_video_height' => '',
  2036. 'allow_player_pause' => 'off',
  2037. 'inner_shadow' => 'off',
  2038. 'parallax' => 'off',
  2039. 'parallax_method' => 'off',
  2040. 'fullwidth' => 'off',
  2041. 'specialty' => 'off',
  2042. 'transparent_background' => 'off',
  2043. ), $atts
  2044. ) );
  2045.  
  2046. $style = $background_video = '';
  2047.  
  2048. if ( '' !== $background_video_mp4 || '' !== $background_video_webm ) {
  2049. $background_video = sprintf(
  2050. '<div class="et_pb_section_video_bg%2$s">
  2051. %1$s
  2052. </div>',
  2053. do_shortcode( sprintf( '
  2054. <video loop="loop" autoplay="autoplay"%3$s%4$s>
  2055. %1$s
  2056. %2$s
  2057. </video>',
  2058. ( '' !== $background_video_mp4 ? sprintf( '<source type="video/mp4" src="%s" />', esc_attr( $background_video_mp4 ) ) : '' ),
  2059. ( '' !== $background_video_webm ? sprintf( '<source type="video/webm" src="%s" />', esc_attr( $background_video_webm ) ) : '' ),
  2060. ( '' !== $background_video_width ? sprintf( ' width="%s"', esc_attr( $background_video_width ) ) : '' ),
  2061. ( '' !== $background_video_height ? sprintf( ' height="%s"', esc_attr( $background_video_height ) ) : '' )
  2062. ) ),
  2063. ( 'on' === $allow_player_pause ? ' et_pb_allow_player_pause' : '' )
  2064. );
  2065.  
  2066. wp_enqueue_style( 'wp-mediaelement' );
  2067. wp_enqueue_script( 'wp-mediaelement' );
  2068. }
  2069.  
  2070.  
  2071. if ( '' !== $background_color && 'off' === $transparent_background )
  2072. $style .= sprintf( 'background-color:%s;',
  2073. esc_attr( $background_color )
  2074. );
  2075.  
  2076. if ( '' !== $background_image && 'on' !== $parallax ) {
  2077. $style .= sprintf( 'background-image:url(%s);',
  2078. esc_attr( $background_image )
  2079. );
  2080. }
  2081.  
  2082. $style = '' !== $style ? " style='{$style}'" : '';
  2083.  
  2084. $output = sprintf(
  2085. '<div%8$s class="et_pb_section%4$s%5$s%6$s%7$s%9$s%13$s%14$s"%2$s>
  2086. %12$s
  2087. %10$s
  2088. %3$s
  2089. %1$s
  2090. %11$s
  2091. </div> <!-- .et_pb_section -->',
  2092. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2093. $style,
  2094. $background_video,
  2095. ( '' !== $background_video ? ' et_pb_section_video et_pb_preload' : '' ),
  2096. ( ( 'off' !== $inner_shadow && ! ( '' !== $background_image && 'on' === $parallax && 'off' === $parallax_method ) ) ? ' et_pb_inner_shadow' : '' ),
  2097. ( 'on' === $parallax ? ' et_pb_section_parallax' : '' ),
  2098. ( 'off' !== $fullwidth ? ' et_pb_fullwidth_section' : '' ),
  2099. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2100. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2101. ( 'on' === $specialty ? '<div class="et_pb_row">' : '' ),
  2102. ( 'on' === $specialty ? '</div> <!-- .et_pb_row -->' : '' ),
  2103. ( '' !== $background_image && 'on' === $parallax
  2104. ? sprintf(
  2105. '<div class="et_parallax_bg%2$s%3$s" style="background-image: url(%1$s);"></div>',
  2106. esc_attr( $background_image ),
  2107. ( 'off' === $parallax_method ? ' et_pb_parallax_css' : '' ),
  2108. ( ( 'off' !== $inner_shadow && 'off' === $parallax_method ) ? ' et_pb_inner_shadow' : '' )
  2109. )
  2110. : ''
  2111. ),
  2112. ( 'on' === $specialty ? ' et_section_specialty' : ' et_section_regular' ),
  2113. ( 'on' === $transparent_background ? ' et_section_transparent' : '' )
  2114. );
  2115.  
  2116. return $output;
  2117. }
  2118.  
  2119. add_shortcode( 'et_pb_row', 'et_pb_row' );
  2120. add_shortcode( 'et_pb_row_inner', 'et_pb_row' );
  2121. function et_pb_row( $atts, $content = '', $shortcode_name ) {
  2122. extract( shortcode_atts( array(
  2123. 'margin' => '',
  2124. ), $atts
  2125. ) );
  2126.  
  2127. $class = 'et_pb_row_inner' !== $shortcode_name ? 'et_pb_row' : 'et_pb_row_inner';
  2128.  
  2129. $inner_content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  2130. $class .= '' == trim( $inner_content ) ? ' et_pb_row_empty' : '';
  2131.  
  2132. $output = sprintf(
  2133. '<div class="%2$s">
  2134. %1$s
  2135. </div> <!-- .%3$s -->',
  2136. $inner_content,
  2137. esc_attr( $class ),
  2138. esc_html( $class )
  2139. );
  2140.  
  2141. return $output;
  2142. }
  2143.  
  2144. add_shortcode( 'et_pb_column', 'et_pb_column' );
  2145. add_shortcode( 'et_pb_column_inner', 'et_pb_column' );
  2146. function et_pb_column( $atts, $content = '', $shortcode_name ) {
  2147. extract( shortcode_atts( array(
  2148. 'type' => '4_4',
  2149. 'specialty_columns' => '',
  2150. ), $atts
  2151. ) );
  2152.  
  2153. global $et_specialty_column_type;
  2154.  
  2155. if ( 'et_pb_column_inner' !== $shortcode_name ) {
  2156. $et_specialty_column_type = $type;
  2157. } else {
  2158. switch ( $et_specialty_column_type ) {
  2159. case '1_2':
  2160. if ( '1_2' === $type ) {
  2161. $type = '1_4';
  2162. }
  2163.  
  2164. break;
  2165. case '2_3':
  2166. if ( '1_2' === $type ) {
  2167. $type = '1_3';
  2168. }
  2169.  
  2170. break;
  2171. case '3_4':
  2172. if ( '1_2' === $type ) {
  2173. $type = '3_8';
  2174. } else if ( '1_3' === $type ) {
  2175. $type = '1_4';
  2176. }
  2177.  
  2178. break;
  2179. }
  2180. }
  2181.  
  2182. $inner_class = 'et_pb_column_inner' === $shortcode_name ? ' et_pb_column_inner' : '';
  2183.  
  2184. $class = 'et_pb_column_' . $type . $inner_class;
  2185.  
  2186. $inner_content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  2187. $class .= '' == trim( $inner_content ) ? ' et_pb_column_empty' : '';
  2188.  
  2189. $output = sprintf(
  2190. '<div class="et_pb_column %1$s">
  2191. %2$s
  2192. </div> <!-- .et_pb_column -->',
  2193. esc_attr( $class ),
  2194. $inner_content
  2195. );
  2196.  
  2197. return $output;
  2198. }
  2199.  
  2200. add_shortcode( 'et_pb_image', 'et_pb_image' );
  2201. function et_pb_image( $atts ) {
  2202. extract( shortcode_atts( array(
  2203. 'module_id' => '',
  2204. 'module_class' => '',
  2205. 'src' => '',
  2206. 'alt' => '',
  2207. 'title_text' => '',
  2208. 'animation' => 'left',
  2209. 'url' => '',
  2210. 'url_new_window' => 'off',
  2211. 'show_in_lightbox' => 'off',
  2212. 'sticky' => 'off',
  2213. ), $atts
  2214. ) );
  2215.  
  2216. $output = sprintf(
  2217. '<img%4$s src="%1$s" alt="%2$s"%6$s class="et-waypoint et_pb_image%3$s%5$s%7$s" />',
  2218. esc_attr( $src ),
  2219. esc_attr( $alt ),
  2220. esc_attr( " et_pb_animation_{$animation}" ),
  2221. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2222. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2223. ( '' !== $title_text ? sprintf( ' title="%1$s"', esc_attr( $title_text ) ) : '' ),
  2224. ( 'on' === $sticky ? esc_attr( ' et_pb_image_sticky' ) : '' )
  2225. );
  2226.  
  2227. if ( 'on' === $show_in_lightbox ) {
  2228. $output = sprintf( '<a href="%1$s" class="et_pb_lightbox_image" title="%3$s">%2$s</a>',
  2229. esc_url( $src ),
  2230. $output,
  2231. esc_attr( $alt )
  2232. );
  2233. } else if ( '' !== $url ) {
  2234. $output = sprintf( '<a href="%1$s"%3$s>%2$s</a>',
  2235. esc_url( $url ),
  2236. $output,
  2237. ( 'on' === $url_new_window ? ' target="_blank"' : '' )
  2238. );
  2239. }
  2240.  
  2241. return $output;
  2242. }
  2243.  
  2244. add_shortcode( 'et_pb_video', 'et_pb_video' );
  2245. function et_pb_video( $atts ) {
  2246. extract( shortcode_atts( array(
  2247. 'module_id' => '',
  2248. 'module_class' => '',
  2249. 'src' => '',
  2250. 'src_webm' => '',
  2251. 'image_src' => '',
  2252. ), $atts
  2253. ) );
  2254.  
  2255. if ( '' !== $image_src ) {
  2256. $image_output = $image_src;
  2257. } else {
  2258. $image_output = '';
  2259. }
  2260.  
  2261. if ( '' !== $src ) {
  2262. if ( false !== et_pb_check_oembed_provider( esc_url( $src ) ) ) {
  2263. $video_src = wp_oembed_get( esc_url( $src ) );
  2264. } else {
  2265. $video_src = sprintf( '
  2266. <video controls>
  2267. %1$s
  2268. %2$s
  2269. </video>',
  2270. ( '' !== $src ? sprintf( '<source type="video/mp4" src="%s" />', esc_url( $src ) ) : '' ),
  2271. ( '' !== $src_webm ? sprintf( '<source type="video/webm" src="%s" />', esc_url( $src_webm ) ) : '' )
  2272. );
  2273.  
  2274. wp_enqueue_style( 'wp-mediaelement' );
  2275. wp_enqueue_script( 'wp-mediaelement' );
  2276. }
  2277. }
  2278.  
  2279. $output = sprintf(
  2280. '<div%2$s class="et_pb_video%3$s">
  2281. <div class="et_pb_video_box">
  2282. %1$s
  2283. </div>
  2284. %4$s
  2285. </div>',
  2286. ( '' !== $video_src ? $video_src : '' ),
  2287. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2288. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2289. ( '' !== $image_output
  2290. ? sprintf(
  2291. '<div class="et_pb_video_overlay" style="background-image: url(%1$s);">
  2292. <div class="et_pb_video_overlay_hover">
  2293. <a href="#" class="et_pb_video_play"></a>
  2294. </div>
  2295. </div>',
  2296. esc_attr( $image_output )
  2297. )
  2298. : ''
  2299. )
  2300. );
  2301.  
  2302. return $output;
  2303. }
  2304.  
  2305. add_shortcode( 'et_pb_video_slider', 'et_pb_video_slider' );
  2306. function et_pb_video_slider( $atts, $content = '' ) {
  2307. extract( shortcode_atts( array(
  2308. 'module_id' => '',
  2309. 'module_class' => '',
  2310. 'show_arrows' => 'on',
  2311. 'show_thumbnails' => 'on',
  2312. 'show_image_overlay' => 'hide',
  2313. 'controls_color' => 'light',
  2314. ), $atts
  2315. ) );
  2316.  
  2317. global $et_pb_slider_image_overlay;
  2318.  
  2319. $et_pb_slider_image_overlay = $show_image_overlay;
  2320.  
  2321. $class = '';
  2322. $class .= 'off' === $show_arrows ? ' et_pb_slider_no_arrows' : '';
  2323. $class .= 'on' === $show_thumbnails ? ' et_pb_slider_carousel et_pb_slider_no_pagination' : '';
  2324. $class .= 'off' === $show_thumbnails ? ' et_pb_slider_dots' : '';
  2325. $class .= " et_pb_controls_{$controls_color}";
  2326.  
  2327. $content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  2328.  
  2329. $output = sprintf(
  2330. '<div%3$s class="et_pb_video_slider%4$s">
  2331. <div class="et_pb_slider et_pb_preload%1$s">
  2332. <div class="et_pb_slides">
  2333. %2$s
  2334. </div> <!-- .et_pb_slides -->
  2335. </div> <!-- .et_pb_slider -->
  2336. </div> <!-- .et_pb_video_slider -->
  2337. ',
  2338. esc_attr( $class ),
  2339. $content,
  2340. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2341. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  2342. );
  2343.  
  2344. return $output;
  2345. }
  2346.  
  2347. add_shortcode( 'et_pb_video_slider_item', 'et_pb_video_slider_item' );
  2348. function et_pb_video_slider_item( $atts, $content = '' ) {
  2349. extract( shortcode_atts( array(
  2350. 'src' => '',
  2351. 'src_webm' => '',
  2352. 'image_src' => '',
  2353. 'background_layout' => 'dark',
  2354. ), $atts
  2355. ) );
  2356.  
  2357. global $et_pb_slider_image_overlay;
  2358.  
  2359. $class = '';
  2360. $class .= " et_pb_bg_layout_{$background_layout}";
  2361.  
  2362. if ( '' !== $image_src ) {
  2363. $image_overlay_output = $image_src;
  2364. $thumbnail_track_output = $image_src;
  2365. } else {
  2366. $image_overlay_output = '';
  2367. if ( false !== et_pb_check_oembed_provider( esc_url( $src ) ) ) {
  2368. add_filter( 'oembed_dataparse', 'et_pb_video_oembed_data_parse', 10, 3 );
  2369. // Save thumbnail
  2370. $thumbnail_track_output = wp_oembed_get( esc_url( $src ) );
  2371. // Set back to normal
  2372. remove_filter( 'oembed_dataparse', 'et_pb_video_oembed_data_parse', 10, 3 );
  2373. } else {
  2374. $thumbnail_track_output = '';
  2375. }
  2376. }
  2377.  
  2378. if ( '' !== $src ) {
  2379. if ( false !== et_pb_check_oembed_provider( esc_url( $src ) ) ) {
  2380. $video_src = wp_oembed_get( esc_url( $src ) );
  2381. } else {
  2382. $video_src = sprintf( '
  2383. <video controls>
  2384. %1$s
  2385. %2$s
  2386. </video>',
  2387. ( '' !== $src ? sprintf( '<source type="video/mp4" src="%s" />', esc_url( $src ) ) : '' ),
  2388. ( '' !== $src_webm ? sprintf( '<source type="video/webm" src="%s" />', esc_url( $src_webm ) ) : '' )
  2389. );
  2390.  
  2391. wp_enqueue_style( 'wp-mediaelement' );
  2392. wp_enqueue_script( 'wp-mediaelement' );
  2393. }
  2394. }
  2395.  
  2396. $video_output = sprintf(
  2397. '<div class="et_pb_video_wrap">
  2398. <div class="et_pb_video_box">
  2399. %1$s
  2400. </div>
  2401. %2$s
  2402. </div>',
  2403. ( '' !== $video_src ? $video_src : '' ),
  2404. (
  2405. ( '' !== $image_overlay_output && $et_pb_slider_image_overlay == 'show' )
  2406. ? sprintf(
  2407. '<div class="et_pb_video_overlay" style="background-image: url(%1$s);">
  2408. <div class="et_pb_video_overlay_hover">
  2409. <a href="#" class="et_pb_video_play"></a>
  2410. </div>
  2411. </div>',
  2412. esc_attr( $image_overlay_output )
  2413. )
  2414. : ''
  2415. )
  2416. );
  2417.  
  2418. $output = sprintf(
  2419. '<div class="et_pb_slide%1$s"%3$s>
  2420. %2$s
  2421. </div> <!-- .et_pb_slide -->
  2422. ',
  2423. esc_attr( $class ),
  2424. ( '' !== $video_output ? $video_output : '' ),
  2425. ( '' !== $thumbnail_track_output ? sprintf( ' data-image="%1$s"', esc_attr( $thumbnail_track_output ) ) : '' )
  2426. );
  2427.  
  2428. return $output;
  2429. }
  2430.  
  2431. add_shortcode( 'et_pb_testimonial', 'et_pb_testimonial' );
  2432. function et_pb_testimonial( $atts, $content = '' ) {
  2433. extract( shortcode_atts( array(
  2434. 'module_id' => '',
  2435. 'module_class' => '',
  2436. 'author' => '',
  2437. 'job_title' => '',
  2438. 'portrait_url' => '',
  2439. 'company_name' => '',
  2440. 'url' => '',
  2441. 'quote_icon' => 'on',
  2442. 'url_new_window' => 'off',
  2443. 'use_background_color' => 'on',
  2444. 'background_color' => '#f5f5f5',
  2445. 'background_layout' => 'dark',
  2446. 'text_orientation' => 'left',
  2447. ), $atts
  2448. ) );
  2449.  
  2450. if ( is_rtl() && 'left' === $text_orientation ) {
  2451. $text_orientation = 'right';
  2452. }
  2453.  
  2454. $portrait_image = '';
  2455.  
  2456. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  2457.  
  2458. if ( ! isset( $atts['quote_icon'] ) ) {
  2459. $class .= " et_pb_testimonial_old_layout";
  2460. }
  2461.  
  2462. if ( '' !== $portrait_url ) {
  2463. $portrait_image = sprintf(
  2464. '<div class="et_pb_testimonial_portrait" style="background-image: url(%1$s);">
  2465. </div>',
  2466. esc_attr( $portrait_url )
  2467. );
  2468. }
  2469.  
  2470. if ( '' !== $url && ( '' !== $company_name || '' !== $author ) ) {
  2471. $link_output = sprintf( '<a href="%1$s"%3$s>%2$s</a>',
  2472. esc_url( $url ),
  2473. ( '' !== $company_name ? esc_html( $company_name ) : esc_html( $author ) ),
  2474. ( 'on' === $url_new_window ? ' target="_blank"' : '' )
  2475. );
  2476.  
  2477. if ( '' !== $company_name ) {
  2478. $company_name = $link_output;
  2479. } else {
  2480. $author = $link_output;
  2481. }
  2482. }
  2483.  
  2484. $output = sprintf(
  2485. '<div%3$s class="et_pb_testimonial%4$s%5$s%9$s%10$s%12$s clearfix"%11$s>
  2486. %8$s
  2487. <div class="et_pb_testimonial_description">
  2488. %1$s
  2489. <strong class="et_pb_testimonial_author">%2$s</strong>
  2490. <p class="et_pb_testimonial_meta">%6$s%7$s</p>
  2491. </div> <!-- .et_pb_testimonial_description -->
  2492. </div> <!-- .et_pb_testimonial -->',
  2493. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2494. $author,
  2495. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2496. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2497. ( 'off' === $quote_icon ? ' et_pb_icon_off' : '' ),
  2498. ( '' !== $job_title ? esc_html( $job_title ) : '' ),
  2499. ( '' !== $company_name
  2500. ? sprintf( '%2$s%1$s',
  2501. $company_name,
  2502. ( '' !== $job_title ? ', ' : '' )
  2503. )
  2504. : ''
  2505. ),
  2506. ( '' !== $portrait_image ? $portrait_image : '' ),
  2507. ( '' === $portrait_image ? ' et_pb_testimonial_no_image' : '' ),
  2508. esc_attr( $class ),
  2509. ( 'on' === $use_background_color
  2510. ? sprintf( ' style="background-color: %1$s;"', esc_attr( $background_color ) )
  2511. : ''
  2512. ),
  2513. ( 'off' === $use_background_color ? ' et_pb_testimonial_no_bg' : '' )
  2514. );
  2515.  
  2516. return $output;
  2517. }
  2518.  
  2519. add_shortcode( 'et_pb_team_member', 'et_pb_team_member' );
  2520. function et_pb_team_member( $atts, $content = '' ) {
  2521. extract( shortcode_atts( array(
  2522. 'module_id' => '',
  2523. 'module_class' => '',
  2524. 'name' => '',
  2525. 'position' => '',
  2526. 'image_url' => '',
  2527. 'animation' => 'off',
  2528. 'facebook_url' => '',
  2529. 'twitter_url' => '',
  2530. 'google_url' => '',
  2531. 'linkedin_url' => '',
  2532. 'background_layout' => 'light',
  2533. ), $atts
  2534. ) );
  2535.  
  2536. $image = $social_links = '';
  2537.  
  2538. if ( '' !== $facebook_url ) {
  2539. $social_links .= sprintf(
  2540. '<li><a href="%1$s" class="et_pb_font_icon et_pb_facebook_icon"><span>%2$s</span></a></li>',
  2541. esc_url( $facebook_url ),
  2542. esc_html__( 'Facebook', 'Divi' )
  2543. );
  2544. }
  2545.  
  2546. if ( '' !== $twitter_url ) {
  2547. $social_links .= sprintf(
  2548. '<li><a href="%1$s" class="et_pb_font_icon et_pb_twitter_icon"><span>%2$s</span></a></li>',
  2549. esc_url( $twitter_url ),
  2550. esc_html__( 'Twitter', 'Divi' )
  2551. );
  2552. }
  2553.  
  2554. if ( '' !== $google_url ) {
  2555. $social_links .= sprintf(
  2556. '<li><a href="%1$s" class="et_pb_font_icon et_pb_google_icon"><span>%2$s</span></a></li>',
  2557. esc_url( $google_url ),
  2558. esc_html__( 'Google+', 'Divi' )
  2559. );
  2560. }
  2561.  
  2562. if ( '' !== $linkedin_url ) {
  2563. $social_links .= sprintf(
  2564. '<li><a href="%1$s" class="et_pb_font_icon et_pb_linkedin_icon"><span>%2$s</span></a></li>',
  2565. esc_url( $linkedin_url ),
  2566. esc_html__( 'LinkedIn', 'Divi' )
  2567. );
  2568. }
  2569.  
  2570. if ( '' !== $social_links ) {
  2571. $social_links = sprintf( '<ul class="et_pb_member_social_links">%1$s</ul>', $social_links );
  2572. }
  2573.  
  2574. if ( '' !== $image_url ) {
  2575. $image = sprintf(
  2576. '<div class="et_pb_team_member_image et-waypoint%3$s">
  2577. <img src="%1$s" alt="%2$s" />
  2578. </div>',
  2579. esc_attr( $image_url ),
  2580. esc_attr( $name ),
  2581. esc_attr( " et_pb_animation_{$animation}" )
  2582. );
  2583. }
  2584.  
  2585. $output = sprintf(
  2586. '<div%3$s class="et_pb_team_member%4$s%9$s et_pb_bg_layout_%8$s clearfix">
  2587. %2$s
  2588. <div class="et_pb_team_member_description">
  2589. %5$s
  2590. %6$s
  2591. %1$s
  2592. %7$s
  2593. </div> <!-- .et_pb_team_member_description -->
  2594. </div> <!-- .et_pb_team_member -->',
  2595. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2596. ( '' !== $image ? $image : '' ),
  2597. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2598. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2599. ( '' !== $name ? sprintf( '<h4>%1$s</h4>', esc_html( $name ) ) : '' ),
  2600. ( '' !== $position ? sprintf( '<p class="et_pb_member_position">%1$s</p>', esc_html( $position ) ) : '' ),
  2601. $social_links,
  2602. $background_layout,
  2603. ( '' === $image ? ' et_pb_team_member_no_image' : '' )
  2604. );
  2605.  
  2606. return $output;
  2607. }
  2608.  
  2609. add_shortcode( 'et_pb_blurb', 'et_pb_blurb' );
  2610. function et_pb_blurb( $atts, $content = '' ) {
  2611. $et_accent_color = et_get_option( 'accent_color', '#7EBEC5' );
  2612.  
  2613. extract( shortcode_atts( array(
  2614. 'module_id' => '',
  2615. 'module_class' => '',
  2616. 'title' => '',
  2617. 'url' => '',
  2618. 'image' => '',
  2619. 'url_new_window' => 'off',
  2620. 'alt' => '',
  2621. 'background_layout' => 'light',
  2622. 'text_orientation' => 'center',
  2623. 'animation' => 'top',
  2624. 'icon_placement' => 'top',
  2625. 'font_icon' => '',
  2626. 'use_icon' => 'off',
  2627. 'use_circle' => 'off',
  2628. 'use_circle_border' => 'off',
  2629. 'icon_color' => $et_accent_color,
  2630. 'circle_color' => $et_accent_color,
  2631. 'circle_border_color' => $et_accent_color,
  2632. ), $atts
  2633. ) );
  2634.  
  2635. if ( is_rtl() && 'left' === $text_orientation ) {
  2636. $text_orientation = 'right';
  2637. }
  2638.  
  2639. if ( is_rtl() && 'left' === $icon_placement ) {
  2640. $icon_placement = 'right';
  2641. }
  2642.  
  2643. if ( '' !== $title && '' !== $url )
  2644. $title = sprintf( '<a href="%1$s"%3$s>%2$s</a>',
  2645. esc_url( $url ),
  2646. esc_html( $title ),
  2647. ( 'on' === $url_new_window ? ' target="_blank"' : '' )
  2648. );
  2649.  
  2650. if ( '' !== $title )
  2651. $title = "<h4>{$title}</h4>";
  2652.  
  2653. if ( '' !== $image || '' !== $font_icon ) {
  2654. if ( 'off' === $use_icon ) {
  2655. $image = sprintf(
  2656. '<img src="%1$s" alt="%2$s" class="et-waypoint%3$s" />',
  2657. esc_attr( $image ),
  2658. esc_attr( $alt ),
  2659. esc_attr( " et_pb_animation_{$animation}" )
  2660. );
  2661. } else {
  2662. $icon_style = sprintf( 'color: %1$s;', esc_attr( $icon_color ) );
  2663.  
  2664. if ( 'on' === $use_circle ) {
  2665. $icon_style .= sprintf( ' background-color: %1$s;', esc_attr( $circle_color ) );
  2666.  
  2667. if ( 'on' === $use_circle_border ) {
  2668. $icon_style .= sprintf( ' border-color: %1$s;', esc_attr( $circle_border_color ) );
  2669. }
  2670. }
  2671.  
  2672. $image = sprintf(
  2673. '<span class="et-pb-icon et-waypoint%2$s%3$s%4$s" style="%5$s">%1$s</span>',
  2674. esc_attr( $font_icon ),
  2675. esc_attr( " et_pb_animation_{$animation}" ),
  2676. ( 'on' === $use_circle ? ' et-pb-icon-circle' : '' ),
  2677. ( 'on' === $use_circle && 'on' === $use_circle_border ? ' et-pb-icon-circle-border' : '' ),
  2678. $icon_style
  2679. );
  2680. }
  2681.  
  2682. $image = sprintf(
  2683. '<div class="et_pb_main_blurb_image">%1$s</div>',
  2684. ( '' !== $url
  2685. ? sprintf(
  2686. '<a href="%1$s"%3$s>%2$s</a>',
  2687. esc_url( $url ),
  2688. $image,
  2689. ( 'on' === $url_new_window ? ' target="_blank"' : '' )
  2690. )
  2691. : $image
  2692. )
  2693. );
  2694. }
  2695.  
  2696. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  2697.  
  2698. $output = sprintf(
  2699. '<div%5$s class="et_pb_blurb%4$s%6$s%7$s">
  2700. <div class="et_pb_blurb_content">
  2701. %2$s
  2702. %3$s
  2703. %1$s
  2704. </div> <!-- .et_pb_blurb_content -->
  2705. </div> <!-- .et_pb_blurb -->',
  2706. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2707. $image,
  2708. $title,
  2709. esc_attr( $class ),
  2710. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2711. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2712. sprintf( ' et_pb_blurb_position_%1$s', esc_attr( $icon_placement ) )
  2713. );
  2714.  
  2715. return $output;
  2716. }
  2717.  
  2718. add_shortcode( 'et_pb_text', 'et_pb_text' );
  2719. function et_pb_text( $atts, $content = '' ) {
  2720. extract( shortcode_atts( array(
  2721. 'module_id' => '',
  2722. 'module_class' => '',
  2723. 'background_layout' => 'light',
  2724. 'text_orientation' => 'left',
  2725. ), $atts
  2726. ) );
  2727.  
  2728. if ( is_rtl() && 'left' === $text_orientation ) {
  2729. $text_orientation = 'right';
  2730. }
  2731.  
  2732. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  2733.  
  2734. $output = sprintf(
  2735. '<div%3$s class="et_pb_text%2$s%4$s">
  2736. %1$s
  2737. </div> <!-- .et_pb_text -->',
  2738. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2739. esc_attr( $class ),
  2740. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2741. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  2742. );
  2743.  
  2744. return $output;
  2745. }
  2746.  
  2747. add_shortcode( 'et_pb_tabs', 'et_pb_tabs' );
  2748. function et_pb_tabs( $atts, $content = '' ) {
  2749. extract( shortcode_atts( array(
  2750. 'module_id' => '',
  2751. 'module_class' => '',
  2752. ), $atts
  2753. ) );
  2754.  
  2755. global $et_pb_tab_titles;
  2756.  
  2757. $et_pb_tab_titles = array();
  2758. $tabs = '';
  2759. $all_tabs_content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  2760.  
  2761. $i = 0;
  2762. foreach ( $et_pb_tab_titles as $tab_title ){
  2763. ++$i;
  2764. $tabs .= sprintf( '<li%1$s><a href="#">%2$s</a></li>',
  2765. ( 1 == $i ? ' class="et_pb_tab_active"' : '' ),
  2766. esc_html( $tab_title )
  2767. );
  2768. }
  2769.  
  2770. $output = sprintf(
  2771. '<div%3$s class="et_pb_tabs%4$s">
  2772. <ul class="et_pb_tabs_controls clearfix">
  2773. %1$s
  2774. </ul>
  2775. <div class="et_pb_all_tabs">
  2776. %2$s
  2777. </div> <!-- .et_pb_all_tabs -->
  2778. </div> <!-- .et_pb_tabs -->',
  2779. $tabs,
  2780. $all_tabs_content,
  2781. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2782. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  2783. );
  2784.  
  2785. return $output;
  2786. }
  2787.  
  2788. add_shortcode( 'et_pb_tab', 'et_pb_tab' );
  2789. function et_pb_tab( $atts, $content = null ) {
  2790. global $et_pb_tab_titles;
  2791.  
  2792. extract( shortcode_atts( array(
  2793. 'title' => '',
  2794. ), $atts
  2795. ) );
  2796.  
  2797. $et_pb_tab_titles[] = '' !== $title ? $title : __( 'Tab', 'Divi' );
  2798.  
  2799. $output = sprintf(
  2800. '<div class="et_pb_tab clearfix%2$s">
  2801. %1$s
  2802. </div> <!-- .et_pb_tab -->',
  2803. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2804. ( 1 === count( $et_pb_tab_titles ) ? ' et_pb_active_content' : '' )
  2805. );
  2806.  
  2807. return $output;
  2808. }
  2809.  
  2810. add_shortcode( 'et_pb_toggle', 'et_pb_toggle' );
  2811. add_shortcode( 'et_pb_accordion_item', 'et_pb_toggle' );
  2812. function et_pb_toggle( $atts, $content = null, $function_name ) {
  2813. extract( shortcode_atts( array(
  2814. 'module_id' => '',
  2815. 'module_class' => '',
  2816. 'title' => '',
  2817. 'open' => 'off',
  2818. ), $atts
  2819. ) );
  2820.  
  2821. if ( 'et_pb_accordion_item' === $function_name ) {
  2822. global $et_pb_accordion_item_number;
  2823.  
  2824. $open = 1 === $et_pb_accordion_item_number ? 'on' : 'off';
  2825.  
  2826. $et_pb_accordion_item_number++;
  2827. }
  2828.  
  2829. $output = sprintf(
  2830. '<div%4$s class="et_pb_toggle %2$s%5$s">
  2831. <h5 class="et_pb_toggle_title">%1$s</h5>
  2832. <div class="et_pb_toggle_content clearfix">
  2833. %3$s
  2834. </div> <!-- .et_pb_toggle_content -->
  2835. </div> <!-- .et_pb_toggle -->',
  2836. esc_html( $title ),
  2837. ( 'on' === $open ? 'et_pb_toggle_open' : 'et_pb_toggle_close' ),
  2838. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2839. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2840. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  2841. );
  2842.  
  2843. return $output;
  2844. }
  2845.  
  2846. add_shortcode( 'et_pb_counters', 'et_pb_counters' );
  2847. function et_pb_counters( $atts, $content = null ) {
  2848. global $et_pb_counters_colors;
  2849.  
  2850. extract( shortcode_atts( array(
  2851. 'module_id' => '',
  2852. 'module_class' => '',
  2853. 'background_layout' => 'light',
  2854. 'background_color' => '#ddd',
  2855. 'bar_bg_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  2856. ), $atts
  2857. ) );
  2858.  
  2859. $et_pb_counters_colors = array(
  2860. 'background_color' => $background_color,
  2861. 'bar_bg_color' => $bar_bg_color,
  2862. );
  2863.  
  2864. $class = " et_pb_bg_layout_{$background_layout}";
  2865.  
  2866. $output = sprintf(
  2867. '<ul%3$s class="et_pb_counters et-waypoint%2$s%4$s">
  2868. %1$s
  2869. </ul> <!-- .et_pb_counters -->',
  2870. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2871. esc_attr( $class ),
  2872. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2873. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  2874. );
  2875.  
  2876. return $output;
  2877. }
  2878.  
  2879. add_shortcode( 'et_pb_counter', 'et_pb_counter' );
  2880. function et_pb_counter( $atts, $content = null ) {
  2881. global $et_pb_counters_colors;
  2882.  
  2883. extract( shortcode_atts( array(
  2884. 'percent' => '0',
  2885. ), $atts
  2886. ) );
  2887.  
  2888. $percent .= '%';
  2889.  
  2890. $background_color_style = $bar_bg_color_style = '';
  2891.  
  2892. if ( isset( $et_pb_counters_colors['background_color'] ) && '' !== $et_pb_counters_colors['background_color'] )
  2893. $background_color_style = sprintf( ' style="background-color: %1$s;"', esc_attr( $et_pb_counters_colors['background_color'] ) );
  2894.  
  2895. if ( isset( $et_pb_counters_colors['bar_bg_color'] ) && '' !== $et_pb_counters_colors['bar_bg_color'] )
  2896. $bar_bg_color_style = sprintf( ' background-color: %1$s;', esc_attr( $et_pb_counters_colors['bar_bg_color'] ) );
  2897.  
  2898. $output = sprintf(
  2899. '<li>
  2900. <span class="et_pb_counter_title">%1$s</span>
  2901. <span class="et_pb_counter_container"%4$s>
  2902. <span class="et_pb_counter_amount" style="width: %3$s;%5$s">%2$s</span>
  2903. </span>
  2904. </li>',
  2905. sanitize_text_field( $content ),
  2906. esc_html( $percent ),
  2907. esc_attr( $percent ),
  2908. $background_color_style,
  2909. $bar_bg_color_style
  2910. );
  2911.  
  2912. return $output;
  2913. }
  2914.  
  2915. add_shortcode( 'et_pb_accordion', 'et_pb_accordion' );
  2916. function et_pb_accordion( $atts, $content = null ) {
  2917. extract( shortcode_atts( array(
  2918. 'module_id' => '',
  2919. 'module_class' => '',
  2920. ), $atts
  2921. ) );
  2922.  
  2923. global $et_pb_accordion_item_number;
  2924.  
  2925. $et_pb_accordion_item_number = 1;
  2926.  
  2927. $output = sprintf(
  2928. '<div%3$s class="et_pb_accordion%2$s">
  2929. %1$s
  2930. </div> <!-- .et_pb_accordion -->',
  2931. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2932. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2933. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' )
  2934. );
  2935.  
  2936. return $output;
  2937. }
  2938.  
  2939. add_shortcode( 'et_pb_social_media_follow', 'et_pb_social_media_follow' );
  2940. function et_pb_social_media_follow( $atts, $content = null ) {
  2941. global $et_pb_social_media_follow_link;
  2942.  
  2943. extract( shortcode_atts( array(
  2944. 'module_id' => '',
  2945. 'module_class' => '',
  2946. 'background_layout' => 'light',
  2947. 'link_shape' => 'rounded_rectangle',
  2948. 'url_new_window' => 'on',
  2949. 'follow_button' => 'off',
  2950. ), $atts
  2951. ) );
  2952.  
  2953. $et_pb_social_media_follow_link = array();
  2954. $et_pb_social_media_follow_link['url_new_window'] = $url_new_window;
  2955. $et_pb_social_media_follow_link['shape'] = $link_shape;
  2956. $et_pb_social_media_follow_link['follow_button'] = $follow_button;
  2957.  
  2958. $class = " et_pb_bg_layout_{$background_layout}";
  2959.  
  2960. $output = sprintf(
  2961. '<ul%3$s class="et_pb_social_media_follow%2$s%4$s%5$s clearfix">
  2962. %1$s
  2963. </ul> <!-- .et_pb_counters -->',
  2964. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  2965. esc_attr( $class ),
  2966. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  2967. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  2968. ( 'on' === $follow_button ? ' has_follow_button' : '' )
  2969. );
  2970.  
  2971. return $output;
  2972. }
  2973.  
  2974. add_shortcode( 'et_pb_social_media_follow_network', 'et_pb_social_media_follow_network' );
  2975. function et_pb_social_media_follow_network ( $atts, $content = null ) {
  2976. global $et_pb_social_media_follow_link;
  2977.  
  2978. extract( shortcode_atts( array(
  2979. 'social_network' => '',
  2980. 'url' => '#',
  2981. 'bg_color' => '#666666',
  2982. 'follow_button' => '', // this is set in parent shortcode, this is just setting the initial var
  2983. ), $atts
  2984. ) );
  2985.  
  2986. if ( isset( $bg_color ) && '' !== $bg_color ) {
  2987. $bg_color_style = sprintf( 'background-color: %1$s;', esc_attr( $bg_color ) );
  2988. }
  2989.  
  2990. if ( 'on' === $et_pb_social_media_follow_link['follow_button'] ) {
  2991. $follow_button = sprintf(
  2992. '<a href="%1$s" class="follow_button" title="%2$s"%3$s>%4$s</a>',
  2993. esc_url( $url ),
  2994. esc_attr( $content ),
  2995. ( 'on' === $et_pb_social_media_follow_link['url_new_window'] ? ' target="_blank"' : '' ),
  2996. esc_html__( 'Follow', 'Divi' )
  2997. );
  2998. }
  2999.  
  3000. $output = sprintf(
  3001. '<li class="et_pb_social_icon et_pb_social_network_link%1$s">
  3002. <a href="%4$s" class="icon%2$s" title="%5$s"%7$s style="%3$s"><span>%6$s</span></a>
  3003. %8$s
  3004. </li>',
  3005. ( '' !== $social_network ? sprintf( ' et-social-%s', esc_attr( $social_network ) ) : '' ),
  3006. ( '' !== $et_pb_social_media_follow_link['shape'] ? sprintf( ' %s', esc_attr( $et_pb_social_media_follow_link['shape'] ) ) : '' ),
  3007. $bg_color_style,
  3008. esc_url( $url ),
  3009. esc_attr( $content ),
  3010. sanitize_text_field( $content ),
  3011. ( 'on' === $et_pb_social_media_follow_link['url_new_window'] ? ' target="_blank"' : '' ),
  3012. $follow_button
  3013. );
  3014.  
  3015. return $output;
  3016. }
  3017.  
  3018. add_shortcode( 'et_pb_countdown_timer', 'et_pb_countdown_timer' );
  3019. function et_pb_countdown_timer( $atts ) {
  3020. extract( shortcode_atts( array(
  3021. 'module_id' => '',
  3022. 'module_class' => '',
  3023. 'title' => '',
  3024. 'date_time' => '',
  3025. 'background_layout' => 'dark',
  3026. 'background_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  3027. 'use_background_color' => 'on',
  3028. ), $atts
  3029. ) );
  3030.  
  3031. $module_id = '' !== $module_id ? sprintf( ' id="%s"', esc_attr( $module_id ) ) : '';
  3032. $module_class = '' !== $module_class ? sprintf( ' %s', esc_attr( $module_class ) ) : '';
  3033.  
  3034. $background_layout = sprintf( ' et_pb_bg_layout_%s', esc_attr( $background_layout ) );
  3035.  
  3036. $end_date = gmdate( 'M d, Y H:i:s', strtotime( $date_time ) );
  3037. $gmt_offset = get_option( 'gmt_offset' );
  3038.  
  3039. if ( '' !== $title ) {
  3040. $title = sprintf( '<h4 class="title">%s</h4>', esc_html( $title ) );
  3041. }
  3042.  
  3043. $background_color_style = '';
  3044. if ( ! empty( $background_color ) && 'on' == $use_background_color ) {
  3045. $background_color_style = sprintf( ' style="background-color: %1$s;"', esc_attr( $background_color ) );
  3046. }
  3047.  
  3048. $output = sprintf(
  3049. '<div%1$s class="et_pb_countdown_timer%2$s%3$s"%4$s data-end-date="%5$s" data-gmt-offset="%6$s">
  3050. <div class="et_pb_countdown_timer_container clearfix">
  3051. %7$s
  3052. <div class="days section values">
  3053. <p class="value"></p>
  3054. <p class="label">%8$s</p>
  3055. </div>
  3056. <div class="sep section"><p>:</p></div>
  3057. <div class="hours section values" data-short="%10$s">
  3058. <p class="value"></p>
  3059. <p class="label">%9$s</p>
  3060. </div>
  3061. <div class="sep section"><p>:</p></div>
  3062. <div class="minutes section values" data-short="%12$s">
  3063. <p class="value"></p>
  3064. <p class="label">%11$s</p>
  3065. </div>
  3066. <div class="sep section"><p>:</p></div>
  3067. <div class="seconds section values" data-short="%14$s">
  3068. <p class="value"></p>
  3069. <p class="label">%13$s</p>
  3070. </div>
  3071. </div>
  3072. </div>',
  3073. $module_id,
  3074. $background_layout,
  3075. $module_class,
  3076. $background_color_style,
  3077. esc_attr( $end_date ),
  3078. esc_attr( $gmt_offset ),
  3079. $title,
  3080. esc_html__( 'Days', 'Divi' ),
  3081. esc_html__( 'Hours', 'Divi' ),
  3082. esc_attr__( 'Hrs', 'Divi' ),
  3083. esc_html__( 'Minutes', 'Divi' ),
  3084. esc_attr__( 'Min', 'Divi' ),
  3085. esc_html__( 'Seconds', 'Divi' ),
  3086. esc_attr__( 'Sec', 'Divi' )
  3087. );
  3088.  
  3089. return $output;
  3090. }
  3091.  
  3092. add_shortcode( 'et_pb_circle_counter', 'et_pb_circle_counter' );
  3093. function et_pb_circle_counter( $atts, $content = null ) {
  3094. wp_enqueue_script( 'easypiechart' );
  3095. extract( shortcode_atts( array(
  3096. 'number' => '0',
  3097. 'percent_sign' => 'on',
  3098. 'title' => '',
  3099. 'module_id' => '',
  3100. 'module_class' => '',
  3101. 'background_layout' => 'light',
  3102. 'bar_bg_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  3103. ), $atts
  3104. ) );
  3105.  
  3106. $number = str_ireplace( '%', '', $number );
  3107.  
  3108. $class = " et_pb_bg_layout_{$background_layout}";
  3109.  
  3110. $output = sprintf(
  3111. '<div%1$s class="et_pb_circle_counter container-width-change-notify%2$s%3$s" data-number-value="%4$s" data-bar-bg-color="%5$s">
  3112. <div class="percent"><p><span class="percent-value"></span>%6$s</p></div>
  3113. %7$s
  3114. </div><!-- .et_pb_circle_counter -->',
  3115. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3116. esc_attr( $class ),
  3117. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  3118. esc_attr( $number ),
  3119. esc_attr( $bar_bg_color ),
  3120. ( 'on' == $percent_sign ? '%' : ''),
  3121. ( '' !== $title ? '<h3>' . esc_html( $title ) . '</h3>' : '' )
  3122. );
  3123.  
  3124. return $output;
  3125. }
  3126.  
  3127. add_shortcode( 'et_pb_number_counter', 'et_pb_number_counter' );
  3128. function et_pb_number_counter( $atts, $content = null ) {
  3129. wp_enqueue_script( 'easypiechart' );
  3130. extract( shortcode_atts( array(
  3131. 'number' => '0',
  3132. 'percent_sign' => 'on',
  3133. 'title' => '',
  3134. 'module_id' => '',
  3135. 'module_class' => '',
  3136. 'counter_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  3137. 'background_layout' => 'light'
  3138. ), $atts
  3139. ) );
  3140.  
  3141. $number = str_ireplace( '%', '', $number );
  3142.  
  3143. $class = " et_pb_bg_layout_{$background_layout}";
  3144.  
  3145. $output = sprintf(
  3146. '<div%1$s class="et_pb_number_counter%2$s%3$s" data-number-value="%4$s">
  3147. <div class="percent" style="%5$s"><p><span class="percent-value"></span>%6$s</p></div>
  3148. %7$s
  3149. </div><!-- .et_pb_number_counter -->',
  3150. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3151. esc_attr( $class ),
  3152. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  3153. esc_attr( $number ),
  3154. sprintf( 'color:%s', esc_attr( $counter_color ) ),
  3155. ( 'on' == $percent_sign ? '%' : ''),
  3156. ( '' !== $title ? '<h3>' . esc_html( $title ) . '</h3>' : '' )
  3157. );
  3158.  
  3159. return $output;
  3160. }
  3161.  
  3162. add_shortcode( 'et_pb_cta', 'et_pb_cta' );
  3163. function et_pb_cta( $atts, $content = null ) {
  3164. extract( shortcode_atts( array(
  3165. 'module_id' => '',
  3166. 'module_class' => '',
  3167. 'title' => '',
  3168. 'button_url' => '',
  3169. 'button_text' => '',
  3170. 'background_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  3171. 'background_layout' => 'dark',
  3172. 'text_orientation' => 'center',
  3173. 'use_background_color' => 'on',
  3174. ), $atts
  3175. ) );
  3176.  
  3177. if ( is_rtl() && 'left' === $text_orientation ) {
  3178. $text_orientation = 'right';
  3179. }
  3180. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  3181.  
  3182. $output = sprintf(
  3183. '<div%6$s class="et_pb_promo%4$s%7$s%8$s"%5$s>
  3184. <div class="et_pb_promo_description">
  3185. %1$s
  3186. %2$s
  3187. </div>
  3188. %3$s
  3189. </div>',
  3190. ( '' !== $title ? '<h2>' . esc_html( $title ) . '</h2>' : '' ),
  3191. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  3192. (
  3193. '' !== $button_url && '' !== $button_text
  3194. ? sprintf( '<a class="et_pb_promo_button" href="%1$s">%2$s</a>',
  3195. esc_url( $button_url ),
  3196. esc_html( $button_text )
  3197. )
  3198. : ''
  3199. ),
  3200. esc_attr( $class ),
  3201. ( 'on' === $use_background_color
  3202. ? sprintf( ' style="background-color: %1$s;"', esc_attr( $background_color ) )
  3203. : ''
  3204. ),
  3205. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3206. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  3207. ( 'on' !== $use_background_color ? ' et_pb_no_bg' : '' )
  3208. );
  3209.  
  3210. return $output;
  3211. }
  3212.  
  3213. add_shortcode( 'et_pb_audio', 'et_pb_audio' );
  3214. function et_pb_audio( $atts, $content = null ) {
  3215. extract( shortcode_atts( array(
  3216. 'module_id' => '',
  3217. 'module_class' => '',
  3218. 'audio' => '',
  3219. 'title' => '',
  3220. 'artist_name' => '',
  3221. 'album_name' => '',
  3222. 'image_url' => '',
  3223. 'button_text' => '',
  3224. 'background_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  3225. 'background_layout' => 'dark',
  3226. ), $atts
  3227. ) );
  3228.  
  3229. $meta = $cover_art = '';
  3230. $class = " et_pb_bg_layout_{$background_layout}";
  3231.  
  3232. if ( 'light' === $background_layout ) {
  3233. $class .= " et_pb_text_color_dark";
  3234. }
  3235.  
  3236. if ( '' !== $artist_name || '' !== $album_name ) {
  3237. if ( '' !== $artist_name && '' !== $album_name ) {
  3238. $album_name = ' | ' . $album_name;
  3239. }
  3240.  
  3241. if ( '' !== $artist_name ) {
  3242. $artist_name = sprintf( _x( 'by <strong>%1$s</strong>', 'Audio Module meta information', 'Divi' ),
  3243. esc_html( $artist_name )
  3244. );
  3245. }
  3246.  
  3247. $meta = sprintf( '%1$s%2$s',
  3248. $artist_name,
  3249. esc_html( $album_name )
  3250. );
  3251.  
  3252. $meta = sprintf( '<p class="et_audio_module_meta">%1$s</p>', $meta );
  3253. }
  3254.  
  3255. if ( '' !== $image_url ) {
  3256. $cover_art = sprintf(
  3257. '<div class="et_pb_audio_cover_art" style="background-image: url(%1$s);">
  3258. </div>',
  3259. esc_attr( $image_url )
  3260. );
  3261. }
  3262.  
  3263. $output = sprintf(
  3264. '<div%8$s class="et_pb_audio_module clearfix%4$s%7$s%9$s"%5$s>
  3265. %6$s
  3266.  
  3267. <div class="et_pb_audio_module_content et_audio_container">
  3268. %1$s
  3269. %2$s
  3270. %3$s
  3271. </div>
  3272. </div>',
  3273. ( '' !== $title ? '<h2>' . esc_html( $title ) . '</h2>' : '' ),
  3274. $meta,
  3275. do_shortcode(
  3276. sprintf( '[audio src="%1$s" /]', esc_attr( $audio ) )
  3277. ),
  3278. esc_attr( $class ),
  3279. sprintf( ' style="background-color: %1$s;"', esc_attr( $background_color ) ),
  3280. $cover_art,
  3281. ( '' === $image_url ? ' et_pb_audio_no_image' : '' ),
  3282. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3283. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  3284. );
  3285.  
  3286. return $output;
  3287. }
  3288.  
  3289. if ( ! function_exists( 'et_pb_get_mailchimp_lists' ) ) :
  3290. function et_pb_get_mailchimp_lists() {
  3291. $lists = array();
  3292.  
  3293. if ( 'on' === et_get_option( 'divi_regenerate_mailchimp_lists', 'false' ) || false === ( $et_pb_mailchimp_lists = get_transient( 'et_pb_mailchimp_lists' ) ) ) {
  3294. if ( ! class_exists( 'MailChimp' ) )
  3295. require_once( get_template_directory() . '/includes/subscription/mailchimp/mailchimp.php' );
  3296.  
  3297. $mailchimp_api_key = et_get_option( 'divi_mailchimp_api_key' );
  3298.  
  3299. if ( '' === $mailchimp_api_key ) return false;
  3300.  
  3301. try {
  3302. $mailchimp = new MailChimp( $mailchimp_api_key );
  3303. $retval = $mailchimp->call('lists/list');
  3304. foreach ( $retval['data'] as $list ) {
  3305. $lists[$list['id']] = $list['name'];
  3306. }
  3307.  
  3308. set_transient( 'et_pb_mailchimp_lists', $lists, 60*60*24 );
  3309. } catch ( Exception $exc ) {
  3310. $lists = $et_pb_mailchimp_lists;
  3311. }
  3312.  
  3313. return $lists;
  3314. }
  3315. }
  3316. endif;
  3317.  
  3318. if ( ! function_exists( 'et_pb_get_aweber_account' ) ) :
  3319. function et_pb_get_aweber_account() {
  3320. if ( ! class_exists( 'AWeberAPI' ) ) {
  3321. require_once( get_template_directory() . '/includes/subscription/aweber/aweber_api.php' );
  3322. }
  3323.  
  3324. $consumer_key = et_get_option( 'divi_aweber_consumer_key' );
  3325. $consumer_secret = et_get_option( 'divi_aweber_consumer_secret' );
  3326. $access_key = et_get_option( 'divi_aweber_access_key' );
  3327. $access_secret = et_get_option( 'divi_aweber_access_secret' );
  3328.  
  3329. if ( ! empty( $consumer_key ) && ! empty( $consumer_secret ) && ! empty( $access_key ) && ! empty( $access_secret ) ) {
  3330. try {
  3331. // Aweber requires curl extension to be enabled
  3332. if ( ! function_exists( 'curl_init' ) ) {
  3333. return false;
  3334. }
  3335.  
  3336. $aweber = new AWeberAPI( $consumer_key, $consumer_secret );
  3337.  
  3338. if ( ! $aweber ) {
  3339. return false;
  3340. }
  3341.  
  3342. $account = $aweber->getAccount( $access_key, $access_secret );
  3343. } catch ( Exception $exc ) {
  3344. return false;
  3345. }
  3346. } else {
  3347. return false;
  3348. }
  3349.  
  3350. return $account;
  3351. }
  3352. endif;
  3353.  
  3354. if ( ! function_exists( 'et_pb_get_aweber_lists' ) ) :
  3355. function et_pb_get_aweber_lists() {
  3356. $lists = array();
  3357.  
  3358. if ( 'on' === et_get_option( 'divi_regenerate_aweber_lists', 'false' ) || false === ( $et_pb_aweber_lists = get_transient( 'et_pb_aweber_lists' ) ) ) {
  3359.  
  3360. if ( ! class_exists( 'AWeberAPI' ) ) {
  3361. require_once( get_template_directory() . '/includes/subscription/aweber/aweber_api.php' );
  3362. }
  3363.  
  3364. $account = et_pb_get_aweber_account();
  3365.  
  3366. if ( ! $account ) {
  3367. return false;
  3368. }
  3369.  
  3370. $aweber_lists = $account->lists;
  3371.  
  3372. if ( isset( $aweber_lists ) ) {
  3373. foreach ( $aweber_lists as $list ) {
  3374. $lists[$list->id] = $list->name;
  3375. }
  3376. }
  3377.  
  3378. set_transient( 'et_pb_aweber_lists', $lists, 60*60*24 );
  3379. } else {
  3380. $lists = $et_pb_aweber_lists;
  3381. }
  3382.  
  3383. return $lists;
  3384. }
  3385. endif;
  3386.  
  3387. function et_pb_submit_subscribe_form() {
  3388. if ( ! wp_verify_nonce( $_POST['et_load_nonce'], 'et_load_nonce' ) ) die( json_encode( array( 'error' => __( 'Configuration error', 'Divi' ) ) ) );
  3389.  
  3390. $service = sanitize_text_field( $_POST['et_service'] );
  3391.  
  3392. $list_id = sanitize_text_field( $_POST['et_list_id'] );
  3393.  
  3394. $email = sanitize_email( $_POST['et_email'] );
  3395.  
  3396. $firstname = sanitize_text_field( $_POST['et_firstname'] );
  3397.  
  3398. if ( '' === $firstname ) die( json_encode( array( 'error' => __( 'Please enter first name', 'Divi' ) ) ) );
  3399.  
  3400. if ( ! is_email( sanitize_email( $_POST['et_email'] ) ) ) die( json_encode( array( 'error' => __( 'Incorrect email', 'Divi' ) ) ) );
  3401.  
  3402. if ( '' == $list_id ) die( json_encode( array( 'error' => __( 'Configuration error: List is not defined', 'Divi' ) ) ) );
  3403.  
  3404. $success_message = __( '<h2 class="et_pb_subscribed">Subscribed - look for the confirmation email!</h2>', 'Divi' );
  3405.  
  3406. switch ( $service ) {
  3407. case 'mailchimp' :
  3408. $lastname = sanitize_text_field( $_POST['et_lastname'] );
  3409. $email = array( 'email' => $email );
  3410.  
  3411. if ( ! class_exists( 'MailChimp' ) )
  3412. require_once( get_template_directory() . '/includes/subscription/mailchimp/mailchimp.php' );
  3413.  
  3414. $mailchimp_api_key = et_get_option( 'divi_mailchimp_api_key' );
  3415.  
  3416. if ( '' === $mailchimp_api_key ) die( json_encode( array( 'error' => __( 'Configuration error: api key is not defined', 'Divi' ) ) ) );
  3417.  
  3418.  
  3419. $mailchimp = new MailChimp( $mailchimp_api_key );
  3420.  
  3421. $merge_vars = array(
  3422. 'FNAME' => $firstname,
  3423. 'LNAME' => $lastname,
  3424. );
  3425.  
  3426. $retval = $mailchimp->call('lists/subscribe', array(
  3427. 'id' => $list_id,
  3428. 'email' => $email,
  3429. 'merge_vars' => $merge_vars,
  3430. ));
  3431.  
  3432. if ( isset($retval['error']) ) {
  3433. if ( '214' == $retval['code'] ){
  3434. $error_message = str_replace( 'Click here to update your profile.', '', $retval['error'] );
  3435. $result = json_encode( array( 'success' => $error_message ) );
  3436. } else {
  3437. $result = json_encode( array( 'success' => $retval['error'] ) );
  3438. }
  3439. } else {
  3440. $result = json_encode( array( 'success' => $success_message ) );
  3441. }
  3442.  
  3443. die( $result );
  3444. break;
  3445. case 'aweber' :
  3446. if ( ! class_exists( 'AWeberAPI' ) ) {
  3447. require_once( get_template_directory() . '/includes/subscription/aweber/aweber_api.php' );
  3448. }
  3449.  
  3450. $account = et_pb_get_aweber_account();
  3451.  
  3452. if ( ! $account ) {
  3453. die( json_encode( array( 'error' => __( 'Aweber: Wrong configuration data', 'Divi' ) ) ) );
  3454. }
  3455.  
  3456. try {
  3457. $list_url = "/accounts/{$account->id}/lists/{$list_id}";
  3458. $list = $account->loadFromUrl( $list_url );
  3459.  
  3460. $new_subscriber = $list->subscribers->create(
  3461. array(
  3462. 'email' => $email,
  3463. 'name' => $firstname,
  3464. )
  3465. );
  3466.  
  3467. die( json_encode( array( 'success' => $success_message ) ) );
  3468. } catch ( Exception $exc ) {
  3469. die( json_encode( array( 'error' => $exc->message ) ) );
  3470. }
  3471.  
  3472. break;
  3473. }
  3474.  
  3475. die();
  3476. }
  3477. add_action( 'wp_ajax_et_pb_submit_subscribe_form', 'et_pb_submit_subscribe_form' );
  3478. add_action( 'wp_ajax_nopriv_et_pb_submit_subscribe_form', 'et_pb_submit_subscribe_form' );
  3479.  
  3480. add_shortcode( 'et_pb_signup', 'et_pb_signup' );
  3481. function et_pb_signup( $atts, $content = null ) {
  3482. extract( shortcode_atts( array(
  3483. 'module_id' => '',
  3484. 'module_class' => '',
  3485. 'title' => '',
  3486. 'button_text' => __( 'Subscribe', 'Divi' ),
  3487. 'background_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  3488. 'background_layout' => 'dark',
  3489. 'mailchimp_list' => '',
  3490. 'aweber_list' => '',
  3491. 'text_orientation' => 'left',
  3492. 'use_background_color' => 'on',
  3493. 'provider' => 'mailchimp',
  3494. 'feedburner_uri' => '',
  3495. ), $atts
  3496. ) );
  3497.  
  3498. if ( is_rtl() && 'left' === $text_orientation ) {
  3499. $text_orientation = 'right';
  3500. }
  3501.  
  3502. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  3503.  
  3504. $form = '';
  3505.  
  3506. $firstname = __( 'First Name', 'Divi' );
  3507. $lastname = __( 'Last Name', 'Divi' );
  3508. $email_address = __( 'Email Address', 'Divi' );
  3509.  
  3510. switch ( $provider ) {
  3511. case 'mailchimp' :
  3512. if ( ! in_array( $mailchimp_list, array( '', 'none' ) ) ) {
  3513. $form = sprintf( '
  3514. <div class="et_pb_newsletter_form">
  3515. <div class="et_pb_newsletter_result"></div>
  3516. <p>
  3517. <label class="et_pb_contact_form_label" for="et_pb_signup_firstname" style="display: none;">%3$s</label>
  3518. <input id="et_pb_signup_firstname" class="input" type="text" value="%4$s" name="et_pb_signup_firstname">
  3519. </p>
  3520. <p>
  3521. <label class="et_pb_contact_form_label" for="et_pb_signup_lastname" style="display: none;">%5$s</label>
  3522. <input id="et_pb_signup_lastname" class="input" type="text" value="%6$s" name="et_pb_signup_lastname">
  3523. </p>
  3524. <p>
  3525. <label class="et_pb_contact_form_label" for="et_pb_signup_email" style="display: none;">%7$s</label>
  3526. <input id="et_pb_signup_email" class="input" type="text" value="%8$s" name="et_pb_signup_email">
  3527. </p>
  3528. <p><a class="et_pb_newsletter_button" href="#"><span class="et_subscribe_loader"></span><span class="et_pb_newsletter_button_text">%1$s</span></a></p>
  3529. <input type="hidden" value="%2$s" name="et_pb_signup_list_id" />
  3530. </div>',
  3531. esc_html( $button_text ),
  3532. ( ! in_array( $mailchimp_list, array( '', 'none' ) ) ? esc_attr( $mailchimp_list ) : '' ),
  3533. esc_html( $firstname ),
  3534. esc_attr( $firstname ),
  3535. esc_html( $lastname ),
  3536. esc_attr( $lastname ),
  3537. esc_html( $email_address ),
  3538. esc_attr( $email_address )
  3539. );
  3540. }
  3541.  
  3542. break;
  3543. case 'feedburner':
  3544. $form = sprintf( '
  3545. <div class="et_pb_newsletter_form et_pb_feedburner_form">
  3546. <form action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="window.open(\'http://feedburner.google.com/fb/a/mailverify?uri=%4$s\', \'popupwindow\', \'scrollbars=yes,width=550,height=520\'); return true">
  3547. <p>
  3548. <label class="et_pb_contact_form_label" for="email" style="display: none;">%2$s</label>
  3549. <input id="email" class="input" type="text" value="%3$s" name="email">
  3550. </p>
  3551. <p><button class="et_pb_newsletter_button" type="submit">%1$s</button></p>
  3552. <input type="hidden" value="%4$s" name="uri" />
  3553. <input type="hidden" name="loc" value="%5$s" />
  3554. </form>
  3555. </div>',
  3556. esc_html( $button_text ),
  3557. esc_html( $email_address ),
  3558. esc_attr( $email_address ),
  3559. esc_attr( $feedburner_uri ),
  3560. esc_attr( get_locale() )
  3561. );
  3562.  
  3563. break;
  3564. case 'aweber' :
  3565. $firstname = __( 'Name', 'Divi' );
  3566.  
  3567. if ( ! in_array( $aweber_list, array( '', 'none' ) ) ) {
  3568. $form = sprintf( '
  3569. <div class="et_pb_newsletter_form" data-service="aweber">
  3570. <div class="et_pb_newsletter_result"></div>
  3571. <p>
  3572. <label class="et_pb_contact_form_label" for="et_pb_signup_firstname" style="display: none;">%3$s</label>
  3573. <input id="et_pb_signup_firstname" class="input" type="text" value="%4$s" name="et_pb_signup_firstname">
  3574. </p>
  3575. <p>
  3576. <label class="et_pb_contact_form_label" for="et_pb_signup_email" style="display: none;">%5$s</label>
  3577. <input id="et_pb_signup_email" class="input" type="text" value="%6$s" name="et_pb_signup_email">
  3578. </p>
  3579. <p><a class="et_pb_newsletter_button" href="#"><span class="et_subscribe_loader"></span><span class="et_pb_newsletter_button_text">%1$s</span></a></p>
  3580. <input type="hidden" value="%2$s" name="et_pb_signup_list_id" />
  3581. </div>',
  3582. esc_html( $button_text ),
  3583. ( ! in_array( $aweber_list, array( '', 'none' ) ) ? esc_attr( $aweber_list ) : '' ),
  3584. esc_html( $firstname ),
  3585. esc_attr( $firstname ),
  3586. esc_html( $email_address ),
  3587. esc_attr( $email_address )
  3588. );
  3589. }
  3590.  
  3591. break;
  3592. }
  3593.  
  3594. $output = sprintf(
  3595. '<div%6$s class="et_pb_newsletter clearfix%4$s%7$s%8$s"%5$s>
  3596. <div class="et_pb_newsletter_description">
  3597. %1$s
  3598. %2$s
  3599. </div>
  3600. %3$s
  3601. </div>',
  3602. ( '' !== $title ? '<h2>' . esc_html( $title ) . '</h2>' : '' ),
  3603. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  3604. $form,
  3605. esc_attr( $class ),
  3606. ( 'on' === $use_background_color
  3607. ? sprintf( ' style="background-color: %1$s;"', esc_attr( $background_color ) )
  3608. : ''
  3609. ),
  3610. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3611. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  3612. ( 'on' !== $use_background_color ? ' et_pb_no_bg' : '' )
  3613. );
  3614.  
  3615. return $output;
  3616. }
  3617.  
  3618. add_shortcode( 'et_pb_login', 'et_pb_login' );
  3619. function et_pb_login( $atts, $content = null ) {
  3620. extract( shortcode_atts( array(
  3621. 'module_id' => '',
  3622. 'module_class' => '',
  3623. 'title' => '',
  3624. 'background_color' => et_get_option( 'accent_color', '#7EBEC5' ),
  3625. 'background_layout' => 'dark',
  3626. 'text_orientation' => 'left',
  3627. 'use_background_color' => 'on',
  3628. 'current_page_redirect' => 'off',
  3629. ), $atts
  3630. ) );
  3631.  
  3632. if ( is_rtl() && 'left' === $text_orientation ) {
  3633. $text_orientation = 'right';
  3634. }
  3635.  
  3636. $redirect_url = 'on' === $current_page_redirect
  3637. ? ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
  3638. : '';
  3639.  
  3640.  
  3641. if ( is_user_logged_in() ) {
  3642. global $current_user;
  3643. get_currentuserinfo();
  3644.  
  3645. $content .= sprintf( '<br/>%1$s <a href="%2$s">%3$s</a>',
  3646. sprintf( __( 'Logged in as %1$s', 'Divi' ), esc_html( $current_user->display_name ) ),
  3647. esc_url( wp_logout_url( $redirect_url ) ),
  3648. esc_html__( 'Log out', 'Divi' )
  3649. );
  3650. }
  3651.  
  3652. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  3653.  
  3654. $form = '';
  3655.  
  3656. if ( !is_user_logged_in() ) {
  3657. $username = __( 'Username', 'Divi' );
  3658. $password = __( 'Password', 'Divi' );
  3659.  
  3660. $form = sprintf( '
  3661. <div class="et_pb_newsletter_form et_pb_login_form">
  3662. <form action="%7$s" method="post">
  3663. <p>
  3664. <label class="et_pb_contact_form_label" for="user_login" style="display: none;">%3$s</label>
  3665. <input id="user_login" placeholder="%4$s" class="input" type="text" value="" name="log" />
  3666. </p>
  3667. <p>
  3668. <label class="et_pb_contact_form_label" for="user_pass" style="display: none;">%5$s</label>
  3669. <input id="user_pass" placeholder="%6$s" class="input" type="password" value="" name="pwd" />
  3670. </p>
  3671. <p class="et_pb_forgot_password"><a href="%2$s">%1$s</a></p>
  3672. <p>
  3673. <button type="submit" class="et_pb_newsletter_button">%8$s</button>
  3674. %9$s
  3675. </p>
  3676. </form>
  3677. </div>',
  3678. __( 'Forgot your password?', 'Divi' ),
  3679. esc_url( wp_lostpassword_url() ),
  3680. esc_html( $username ),
  3681. esc_attr( $username ),
  3682. esc_html( $password ),
  3683. esc_attr( $password ),
  3684. esc_url( site_url( 'wp-login.php', 'login_post' ) ),
  3685. __( 'Login', 'Divi' ),
  3686. ( 'on' === $current_page_redirect
  3687. ? sprintf( '<input type="hidden" name="redirect_to" value="%1$s" />', $redirect_url )
  3688. : ''
  3689. )
  3690. );
  3691. }
  3692.  
  3693. $output = sprintf(
  3694. '<div%6$s class="et_pb_newsletter et_pb_login clearfix%4$s%7$s"%5$s>
  3695. <div class="et_pb_newsletter_description">
  3696. %1$s
  3697. %2$s
  3698. </div>
  3699. %3$s
  3700. </div>',
  3701. ( '' !== $title ? '<h2>' . esc_html( $title ) . '</h2>' : '' ),
  3702. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  3703. $form,
  3704. esc_attr( $class ),
  3705. ( 'on' === $use_background_color
  3706. ? sprintf( ' style="background-color: %1$s;"', esc_attr( $background_color ) )
  3707. : ''
  3708. ),
  3709. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3710. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  3711. );
  3712.  
  3713. return $output;
  3714. }
  3715.  
  3716. add_shortcode( 'et_pb_sidebar', 'et_pb_sidebar' );
  3717. function et_pb_sidebar( $atts ) {
  3718. extract( shortcode_atts( array(
  3719. 'module_id' => '',
  3720. 'module_class' => '',
  3721. 'orientation' => 'left',
  3722. 'area' => '',
  3723. 'background_layout' => 'light',
  3724. ), $atts
  3725. ) );
  3726.  
  3727. $widgets = '';
  3728.  
  3729. ob_start();
  3730.  
  3731. if ( is_active_sidebar( $area ) )
  3732. dynamic_sidebar( $area );
  3733.  
  3734. $widgets = ob_get_contents();
  3735.  
  3736. ob_end_clean();
  3737.  
  3738. $class = " et_pb_bg_layout_{$background_layout}";
  3739.  
  3740. $output = sprintf(
  3741. '<div%4$s class="et_pb_widget_area %2$s clearfix%3$s%5$s">
  3742. %1$s
  3743. </div> <!-- .et_pb_widget_area -->',
  3744. $widgets,
  3745. esc_attr( "et_pb_widget_area_{$orientation}" ),
  3746. esc_attr( $class ),
  3747. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3748. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  3749. );
  3750.  
  3751. return $output;
  3752. }
  3753.  
  3754. add_shortcode( 'et_pb_blog', 'et_pb_blog' );
  3755. function et_pb_blog( $atts ) {
  3756. extract( shortcode_atts( array(
  3757. 'module_id' => '',
  3758. 'module_class' => '',
  3759. 'fullwidth' => 'on',
  3760. 'posts_number' => 10,
  3761. 'include_categories' => '',
  3762. 'meta_date' => 'M j, Y',
  3763. 'show_thumbnail' => 'on',
  3764. 'show_content' => 'off',
  3765. 'show_author' => 'on',
  3766. 'show_date' => 'on',
  3767. 'show_categories' => 'on',
  3768. 'show_pagination' => 'on',
  3769. 'offset_number' => 0,
  3770. 'background_layout' => 'light',
  3771. 'show_more' => 'off',
  3772. ), $atts
  3773. ) );
  3774.  
  3775. global $paged;
  3776.  
  3777. $container_is_closed = false;
  3778.  
  3779. if ( 'on' !== $fullwidth ){
  3780. wp_enqueue_script( 'jquery-masonry-3' );
  3781.  
  3782. $background_layout = 'light';
  3783. }
  3784.  
  3785. $args = array( 'posts_per_page' => (int) $posts_number );
  3786.  
  3787. $et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
  3788.  
  3789. if ( is_front_page() ) {
  3790. $paged = $et_paged;
  3791. }
  3792.  
  3793. if ( '' !== $include_categories )
  3794. $args['cat'] = $include_categories;
  3795.  
  3796. if ( ! is_search() ) {
  3797. $args['paged'] = $et_paged;
  3798. }
  3799.  
  3800. if ( '' !== $offset_number && ! empty( $offset_number ) ) {
  3801. $args['offset'] = (int) $offset_number;
  3802. }
  3803.  
  3804. ob_start();
  3805.  
  3806. query_posts( $args );
  3807.  
  3808. if ( have_posts() ) {
  3809. while ( have_posts() ) {
  3810. the_post();
  3811.  
  3812. $post_format = get_post_format();
  3813.  
  3814. $thumb = '';
  3815.  
  3816. $width = 'on' === $fullwidth ? 1080 : 400;
  3817. $width = (int) apply_filters( 'et_pb_blog_image_width', $width );
  3818.  
  3819. $height = 'on' === $fullwidth ? 675 : 250;
  3820. $height = (int) apply_filters( 'et_pb_blog_image_height', $height );
  3821. $classtext = 'on' === $fullwidth ? 'et_pb_post_main_image' : '';
  3822. $titletext = get_the_title();
  3823. $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
  3824. $thumb = $thumbnail["thumb"];
  3825.  
  3826. $no_thumb_class = '' === $thumb || 'off' === $show_thumbnail ? ' et_pb_no_thumb' : '';
  3827.  
  3828. if ( in_array( $post_format, array( 'video', 'gallery' ) ) ) {
  3829. $no_thumb_class = '';
  3830. } ?>
  3831.  
  3832. <article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' . $no_thumb_class ); ?>>
  3833.  
  3834. <?php
  3835. et_divi_post_format_content();
  3836.  
  3837. if ( ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) ) {
  3838. if ( 'video' === $post_format && false !== ( $first_video = et_get_first_video() ) ) :
  3839. printf(
  3840. '<div class="et_main_video_container">
  3841. %1$s
  3842. </div>',
  3843. $first_video
  3844. );
  3845. elseif ( 'gallery' === $post_format ) :
  3846. et_gallery_images();
  3847. elseif ( '' !== $thumb && 'on' === $show_thumbnail ) :
  3848. if ( 'on' !== $fullwidth ) echo '<div class="et_pb_image_container">'; ?>
  3849. <a href="<?php the_permalink(); ?>">
  3850. <?php print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
  3851. </a>
  3852. <?php
  3853. if ( 'on' !== $fullwidth ) echo '</div> <!-- .et_pb_image_container -->';
  3854. endif;
  3855. } ?>
  3856.  
  3857. <?php if ( 'off' === $fullwidth || ! in_array( $post_format, array( 'link', 'audio', 'quote', 'gallery' ) ) ) { ?>
  3858. <?php if ( ! in_array( $post_format, array( 'link', 'audio' ) ) ) { ?>
  3859. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  3860. <?php } ?>
  3861.  
  3862. <?php
  3863. if ( 'on' === $show_author || 'on' === $show_date || 'on' === $show_categories ) {
  3864. printf( '<p class="post-meta">%1$s %2$s %3$s %4$s %5$s</p>',
  3865. (
  3866. 'on' === $show_author
  3867. ? sprintf( __( 'by %s', 'Divi' ), et_get_the_author_posts_link() )
  3868. : ''
  3869. ),
  3870. (
  3871. ( 'on' === $show_author && 'on' === $show_date )
  3872. ? ' | '
  3873. : ''
  3874. ),
  3875. (
  3876. 'on' === $show_date
  3877. ? sprintf( __( '%s', 'Divi' ), get_the_date( $meta_date ) )
  3878. : ''
  3879. ),
  3880. (
  3881. (( 'on' === $show_author || 'on' === $show_date ) && 'on' === $show_categories)
  3882. ? ' | '
  3883. : ''
  3884. ),
  3885. (
  3886. 'on' === $show_categories
  3887. ? get_the_category_list(', ')
  3888. : ''
  3889. )
  3890. );
  3891. }
  3892.  
  3893. if ( 'on' === $show_content ) {
  3894. global $more;
  3895. $more = null;
  3896.  
  3897. the_content( __( 'read more...', 'Divi' ) );
  3898. } else {
  3899. if ( has_excerpt() ) {
  3900. the_excerpt();
  3901. } else {
  3902. truncate_post( 270 );
  3903. }
  3904. $more = 'on' == $show_more ? sprintf( ' <a href="%1$s" class="more-link" >%2$s</a>' , esc_url( get_permalink() ), __( 'read more', 'Divi' ) ) : '';
  3905. echo $more;
  3906. } ?>
  3907. <?php } // 'off' === $fullwidth || ! in_array( $post_format, array( 'link', 'audio', 'quote', 'gallery' ?>
  3908.  
  3909. </article> <!-- .et_pb_post -->
  3910. <?php
  3911. } // endwhile
  3912.  
  3913. if ( 'on' === $show_pagination && ! is_search() ) {
  3914. echo '</div> <!-- .et_pb_posts -->';
  3915.  
  3916. $container_is_closed = true;
  3917.  
  3918. if ( function_exists( 'wp_pagenavi' ) )
  3919. wp_pagenavi();
  3920. else
  3921. get_template_part( 'includes/navigation', 'index' );
  3922. }
  3923.  
  3924. wp_reset_query();
  3925. } else {
  3926. get_template_part( 'includes/no-results', 'index' );
  3927. }
  3928.  
  3929. $posts = ob_get_contents();
  3930.  
  3931. ob_end_clean();
  3932.  
  3933. $class = " et_pb_bg_layout_{$background_layout}";
  3934.  
  3935. $output = sprintf(
  3936. '<div%5$s class="%1$s%3$s%6$s">
  3937. %2$s
  3938. %4$s',
  3939. ( 'on' === $fullwidth ? 'et_pb_posts' : 'et_pb_blog_grid clearfix' ),
  3940. $posts,
  3941. esc_attr( $class ),
  3942. ( ! $container_is_closed ? '</div> <!-- .et_pb_posts -->' : '' ),
  3943. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  3944. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  3945. );
  3946.  
  3947. if ( 'on' !== $fullwidth )
  3948. $output = sprintf( '<div class="et_pb_blog_grid_wrapper">%1$s</div>', $output );
  3949.  
  3950. return $output;
  3951. }
  3952.  
  3953. add_shortcode( 'et_pb_gallery', 'et_pb_gallery' );
  3954. function et_pb_gallery( $atts ) {
  3955. extract(shortcode_atts(array(
  3956. 'module_id' => '',
  3957. 'module_class' => '',
  3958. 'gallery_ids' => '',
  3959. 'fullwidth' => 'off',
  3960. 'show_title_and_caption' => 'on',
  3961. 'background_layout' => 'light',
  3962. 'posts_number' => 4,
  3963. 'show_pagination' => 'on',
  3964. 'gallery_orderby' => '',
  3965. ), $atts ));
  3966.  
  3967. $attachments = array();
  3968. if ( !empty($gallery_ids) ) {
  3969. $attachments_args = array(
  3970. 'include' => $gallery_ids,
  3971. 'post_status' => 'inherit',
  3972. 'post_type' => 'attachment',
  3973. 'post_mime_type' => 'image',
  3974. 'order' => 'ASC',
  3975. 'orderby' => 'post__in',
  3976. );
  3977.  
  3978. if ( 'rand' === $gallery_orderby ) {
  3979. $attachments_args['orderby'] = 'rand';
  3980. }
  3981.  
  3982. $_attachments = get_posts( $attachments_args );
  3983.  
  3984. foreach ( $_attachments as $key => $val ) {
  3985. $attachments[$val->ID] = $_attachments[$key];
  3986. }
  3987. }
  3988.  
  3989. if ( empty($attachments) )
  3990. return '';
  3991.  
  3992. wp_enqueue_script( 'jquery-masonry-3' );
  3993. wp_enqueue_script( 'hashchange' );
  3994.  
  3995. $fullwidth_class = 'on' === $fullwidth ? ' et_pb_slider et_pb_gallery_fullwidth' : ' et_pb_gallery_grid';
  3996. $background_class = " et_pb_bg_layout_{$background_layout}";
  3997.  
  3998. $output = sprintf(
  3999. '<div%1$s class="et_pb_gallery%2$s%3$s%4$s clearfix">
  4000. %5$s
  4001. <div class="et_pb_gallery_items et_post_gallery" data-per_page="%6$d">',
  4002. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4003. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  4004. esc_attr( $fullwidth_class ),
  4005. esc_attr( $background_class ),
  4006. ( 'on' !== $fullwidth ? '<div class="column_width"></div><div class="gutter_width"></div>' : '' ),
  4007. esc_attr( $posts_number )
  4008. );
  4009.  
  4010. $i = 0;
  4011. foreach ( $attachments as $id => $attachment ) {
  4012.  
  4013. $width = 'on' === $fullwidth ? 1080 : 400;
  4014. $width = (int) apply_filters( 'et_pb_gallery_image_width', $width );
  4015.  
  4016. $height = 'on' === $fullwidth ? 9999 : 284;
  4017. $height = (int) apply_filters( 'et_pb_gallery_image_height', $height );
  4018.  
  4019. list($full_src, $full_width, $full_height) = wp_get_attachment_image_src( $id, 'full' );
  4020. list($thumb_src, $thumb_width, $thumb_height) = wp_get_attachment_image_src( $id, array( $width, $height ) );
  4021.  
  4022. $image_output = sprintf(
  4023. '<a href="%1$s" title="%2$s">
  4024. <img src="%3$s" alt="%2$s" /><span class="et_overlay"></span>
  4025. </a>',
  4026. esc_attr( $full_src ),
  4027. esc_attr( $attachment->post_title ),
  4028. esc_attr( $thumb_src )
  4029. );
  4030.  
  4031. $orientation = ( $thumb_height > $thumb_width ) ? 'portrait' : 'landscape';
  4032.  
  4033. $output .= sprintf(
  4034. '<div class="et_pb_gallery_item%1$s">',
  4035. esc_attr( $background_class )
  4036. );
  4037. $output .= "
  4038. <div class='et_pb_gallery_image {$orientation}'>
  4039. $image_output
  4040. </div>";
  4041.  
  4042. if ( 'on' !== $fullwidth && 'on' === $show_title_and_caption ) {
  4043. if ( trim($attachment->post_title) ) {
  4044. $output .= "
  4045. <h3 class='et_pb_gallery_title'>
  4046. " . wptexturize($attachment->post_title) . "
  4047. </h3>";
  4048. }
  4049. if ( trim($attachment->post_excerpt) ) {
  4050. $output .= "
  4051. <p class='et_pb_gallery_caption'>
  4052. " . wptexturize($attachment->post_excerpt) . "
  4053. </p>";
  4054. }
  4055. }
  4056. $output .= "</div>";
  4057. }
  4058.  
  4059. $output .= "</div><!-- .et_pb_gallery_items -->";
  4060.  
  4061. if ( 'on' !== $fullwidth && 'on' === $show_pagination ) {
  4062. $output .= "<div class='et_pb_gallery_pagination'></div>";
  4063. }
  4064.  
  4065. $output .= "</div><!-- .et_pb_gallery -->";
  4066.  
  4067. return $output;
  4068. }
  4069.  
  4070. add_shortcode( 'et_pb_portfolio', 'et_pb_portfolio' );
  4071. function et_pb_portfolio( $atts ) {
  4072. extract( shortcode_atts( array(
  4073. 'module_id' => '',
  4074. 'module_class' => '',
  4075. 'fullwidth' => 'on',
  4076. 'posts_number' => 10,
  4077. 'include_categories' => '',
  4078. 'show_title' => 'on',
  4079. 'show_categories' => 'on',
  4080. 'show_pagination' => 'on',
  4081. 'background_layout' => 'light',
  4082. ), $atts
  4083. ) );
  4084.  
  4085. global $paged;
  4086.  
  4087. $container_is_closed = false;
  4088.  
  4089. $args = array(
  4090. 'posts_per_page' => (int) $posts_number,
  4091. 'post_type' => 'project',
  4092. );
  4093.  
  4094. $et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
  4095.  
  4096. if ( is_front_page() ) {
  4097. $paged = $et_paged;
  4098. }
  4099.  
  4100. if ( '' !== $include_categories )
  4101. $args['tax_query'] = array(
  4102. array(
  4103. 'taxonomy' => 'project_category',
  4104. 'field' => 'id',
  4105. 'terms' => explode( ',', $include_categories ),
  4106. 'operator' => 'IN',
  4107. )
  4108. );
  4109.  
  4110. if ( ! is_search() ) {
  4111. $args['paged'] = $et_paged;
  4112. }
  4113.  
  4114. ob_start();
  4115.  
  4116. query_posts( $args );
  4117.  
  4118. if ( have_posts() ) {
  4119. while ( have_posts() ) {
  4120. the_post(); ?>
  4121.  
  4122. <div id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_portfolio_item' ); ?>>
  4123.  
  4124. <?php
  4125. $thumb = '';
  4126.  
  4127. $width = 'on' === $fullwidth ? 1080 : 400;
  4128. $width = (int) apply_filters( 'et_pb_portfolio_image_width', $width );
  4129.  
  4130. $height = 'on' === $fullwidth ? 9999 : 284;
  4131. $height = (int) apply_filters( 'et_pb_portfolio_image_height', $height );
  4132. $classtext = 'on' === $fullwidth ? 'et_pb_post_main_image' : '';
  4133. $titletext = get_the_title();
  4134. $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
  4135. $thumb = $thumbnail["thumb"];
  4136.  
  4137. if ( '' !== $thumb ) : ?>
  4138. <a href="<?php the_permalink(); ?>">
  4139. <?php if ( 'on' !== $fullwidth ) : ?>
  4140. <span class="et_portfolio_image">
  4141. <?php endif; ?>
  4142. <?php print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
  4143. <?php if ( 'on' !== $fullwidth ) : ?>
  4144. <span class="et_overlay"></span>
  4145. </span>
  4146. <?php endif; ?>
  4147. </a>
  4148. <?php
  4149. endif;
  4150. ?>
  4151.  
  4152. <?php if ( 'on' === $show_title ) : ?>
  4153. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  4154. <?php endif; ?>
  4155.  
  4156. <?php if ( 'on' === $show_categories ) : ?>
  4157. <p class="post-meta"><?php echo get_the_term_list( get_the_ID(), 'project_category', '', ', ' ); ?></p>
  4158. <?php endif; ?>
  4159.  
  4160. </div> <!-- .et_pb_portfolio_item -->
  4161. <?php }
  4162.  
  4163. if ( 'on' === $show_pagination && ! is_search() ) {
  4164. echo '</div> <!-- .et_pb_portfolio -->';
  4165.  
  4166. $container_is_closed = true;
  4167.  
  4168. if ( function_exists( 'wp_pagenavi' ) )
  4169. wp_pagenavi();
  4170. else
  4171. get_template_part( 'includes/navigation', 'index' );
  4172. }
  4173.  
  4174. wp_reset_query();
  4175. } else {
  4176. get_template_part( 'includes/no-results', 'index' );
  4177. }
  4178.  
  4179. $posts = ob_get_contents();
  4180.  
  4181. ob_end_clean();
  4182.  
  4183. $class = " et_pb_bg_layout_{$background_layout}";
  4184.  
  4185. $output = sprintf(
  4186. '<div%5$s class="%1$s%3$s%6$s">
  4187. %2$s
  4188. %4$s',
  4189. ( 'on' === $fullwidth ? 'et_pb_portfolio' : 'et_pb_portfolio_grid clearfix' ),
  4190. $posts,
  4191. esc_attr( $class ),
  4192. ( ! $container_is_closed ? '</div> <!-- .et_pb_portfolio -->' : '' ),
  4193. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4194. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  4195. );
  4196.  
  4197. return $output;
  4198. }
  4199.  
  4200. if ( ! function_exists( 'et_divi_get_projects' ) ) :
  4201. function et_divi_get_projects( $args = array() ) {
  4202.  
  4203. $default_args = array(
  4204. 'post_type' => 'project',
  4205. );
  4206.  
  4207. $args = wp_parse_args( $args, $default_args );
  4208.  
  4209. return new WP_Query( $args );
  4210.  
  4211. }
  4212. endif;
  4213.  
  4214. add_shortcode( 'et_pb_filterable_portfolio', 'et_pb_filterable_portfolio' );
  4215. function et_pb_filterable_portfolio( $atts ) {
  4216. extract( shortcode_atts( array(
  4217. 'module_id' => '',
  4218. 'module_class' => '',
  4219. 'fullwidth' => 'on',
  4220. 'posts_number' => 10,
  4221. 'include_categories' => '',
  4222. 'show_title' => 'on',
  4223. 'show_categories' => 'on',
  4224. 'show_pagination' => 'on',
  4225. 'background_layout' => 'light',
  4226. ), $atts
  4227. ) );
  4228.  
  4229. wp_enqueue_script( 'jquery-masonry-3' );
  4230. wp_enqueue_script( 'hashchange' );
  4231.  
  4232. $args = array();
  4233.  
  4234. if( 'on' === $show_pagination ) {
  4235. $args['nopaging'] = true;
  4236. } else {
  4237. $args['posts_per_page'] = (int) $posts_number;
  4238. }
  4239.  
  4240. if ( '' !== $include_categories ) {
  4241. $args['tax_query'] = array(
  4242. array(
  4243. 'taxonomy' => 'project_category',
  4244. 'field' => 'id',
  4245. 'terms' => explode( ',', $include_categories ),
  4246. 'operator' => 'IN',
  4247. )
  4248. );
  4249. }
  4250.  
  4251. $projects = et_divi_get_projects( $args );
  4252.  
  4253. $categories_included = array();
  4254. ob_start();
  4255. if( $projects->post_count > 0 ) {
  4256. while ( $projects->have_posts() ) {
  4257. $projects->the_post();
  4258.  
  4259. $category_classes = array();
  4260. $categories = get_the_terms( get_the_ID(), 'project_category' );
  4261. if ( $categories ) {
  4262. foreach ( $categories as $category ) {
  4263. $category_classes[] = 'project_category_' . urldecode( $category->slug );
  4264. $categories_included[] = $category->term_id;
  4265. }
  4266. }
  4267.  
  4268. $category_classes = implode( ' ', $category_classes );
  4269.  
  4270. ?>
  4271. <div id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_portfolio_item ' . $category_classes ); ?>>
  4272. <?php
  4273. $thumb = '';
  4274.  
  4275. $width = 'on' === $fullwidth ? 1080 : 400;
  4276. $width = (int) apply_filters( 'et_pb_portfolio_image_width', $width );
  4277.  
  4278. $height = 'on' === $fullwidth ? 9999 : 284;
  4279. $height = (int) apply_filters( 'et_pb_portfolio_image_height', $height );
  4280. $classtext = 'on' === $fullwidth ? 'et_pb_post_main_image' : '';
  4281. $titletext = get_the_title();
  4282. $thumbnail = get_thumbnail( $width, $height, $classtext, $titletext, $titletext, false, 'Blogimage' );
  4283. $thumb = $thumbnail["thumb"];
  4284.  
  4285. if ( '' !== $thumb ) : ?>
  4286. <a href="<?php the_permalink(); ?>">
  4287. <?php if ( 'on' !== $fullwidth ) : ?>
  4288. <span class="et_portfolio_image">
  4289. <?php endif; ?>
  4290. <?php print_thumbnail( $thumb, $thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
  4291. <?php if ( 'on' !== $fullwidth ) : ?>
  4292. <span class="et_overlay"></span>
  4293. </span>
  4294. <?php endif; ?>
  4295. </a>
  4296. <?php
  4297. endif;
  4298. ?>
  4299.  
  4300. <?php if ( 'on' === $show_title ) : ?>
  4301. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  4302. <?php endif; ?>
  4303.  
  4304. <?php if ( 'on' === $show_categories ) : ?>
  4305. <p class="post-meta"><?php echo get_the_term_list( get_the_ID(), 'project_category', '', ', ' ); ?></p>
  4306. <?php endif; ?>
  4307.  
  4308. </div><!-- .et_pb_portfolio_item -->
  4309. <?php
  4310. }
  4311. }
  4312.  
  4313. wp_reset_postdata();
  4314.  
  4315. $posts = ob_get_clean();
  4316.  
  4317. $categories_included = explode ( ',', $include_categories );
  4318. $terms_args = array(
  4319. 'include' => $categories_included,
  4320. 'orderby' => 'name',
  4321. 'order' => 'ASC',
  4322. );
  4323. $terms = get_terms( 'project_category', $terms_args );
  4324.  
  4325. $category_filters = '<ul class="clearfix">';
  4326. $category_filters .= sprintf( '<li class="et_pb_portfolio_filter et_pb_portfolio_filter_all"><a href="#" class="active" data-category-slug="all">%1$s</a></li>',
  4327. esc_html__( 'All', 'Divi' )
  4328. );
  4329. foreach ( $terms as $term ) {
  4330. $category_filters .= sprintf( '<li class="et_pb_portfolio_filter"><a href="#" data-category-slug="%1$s">%2$s</a></li>',
  4331. esc_attr( urldecode( $term->slug ) ),
  4332. esc_html( $term->name )
  4333. );
  4334. }
  4335. $category_filters .= '</ul>';
  4336.  
  4337. $class = " et_pb_bg_layout_{$background_layout}";
  4338.  
  4339. $output = sprintf(
  4340. '<div%5$s class="et_pb_filterable_portfolio %1$s%4$s%6$s" data-posts-number="%7$d"%10$s>
  4341. <div class="et_pb_portfolio_filters clearfix">%2$s</div><!-- .et_pb_portfolio_filters -->
  4342.  
  4343. <div class="et_pb_portfolio_items_wrapper %8$s">
  4344. <div class="column_width"></div>
  4345. <div class="gutter_width"></div>
  4346. <div class="et_pb_portfolio_items">%3$s</div><!-- .et_pb_portfolio_items -->
  4347. </div>
  4348. %9$s
  4349. </div> <!-- .et_pb_filterable_portfolio -->',
  4350. ( 'on' === $fullwidth ? 'et_pb_filterable_portfolio_fullwidth' : 'et_pb_filterable_portfolio_grid clearfix' ),
  4351. $category_filters,
  4352. $posts,
  4353. esc_attr( $class ),
  4354. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4355. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  4356. esc_attr( $posts_number),
  4357. ('on' === $show_pagination ? '' : 'no_pagination' ),
  4358. ('on' === $show_pagination ? '<div class="et_pb_portofolio_pagination"></div>' : '' ),
  4359. is_rtl() ? ' data-rtl="true"' : ''
  4360. );
  4361.  
  4362. return $output;
  4363. }
  4364.  
  4365. add_shortcode( 'et_pb_fullwidth_portfolio', 'et_pb_fullwidth_portfolio' );
  4366. function et_pb_fullwidth_portfolio( $atts ) {
  4367. extract( shortcode_atts( array(
  4368. 'title' => '',
  4369. 'module_id' => '',
  4370. 'module_class' => '',
  4371. 'fullwidth' => 'on',
  4372. 'include_categories' => '',
  4373. 'posts_number' => '',
  4374. 'show_title' => 'on',
  4375. 'show_date' => 'on',
  4376. 'background_layout' => 'light',
  4377. 'auto' => 'off',
  4378. 'auto_speed' => 7000,
  4379. ), $atts
  4380. ) );
  4381.  
  4382. $args = array();
  4383. if ( is_numeric( $posts_number ) && $posts_number > 0 ) {
  4384. $args['posts_per_page'] = $posts_number;
  4385. } else {
  4386. $args['nopaging'] = true;
  4387. }
  4388.  
  4389. if ( '' !== $include_categories ) {
  4390. $args['tax_query'] = array(
  4391. array(
  4392. 'taxonomy' => 'project_category',
  4393. 'field' => 'id',
  4394. 'terms' => explode( ',', $include_categories ),
  4395. 'operator' => 'IN'
  4396. )
  4397. );
  4398. }
  4399.  
  4400. $projects = et_divi_get_projects( $args );
  4401.  
  4402. ob_start();
  4403. if( $projects->post_count > 0 ) {
  4404. while ( $projects->have_posts() ) {
  4405. $projects->the_post();
  4406. ?>
  4407. <div id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_portfolio_item ' ); ?>>
  4408. <?php
  4409. $thumb = '';
  4410.  
  4411. $width = 320;
  4412. $width = (int) apply_filters( 'et_pb_portfolio_image_width', $width );
  4413.  
  4414. $height = 241;
  4415. $height = (int) apply_filters( 'et_pb_portfolio_image_height', $height );
  4416.  
  4417. list($thumb_src, $thumb_width, $thumb_height) = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), array( $width, $height ) );
  4418.  
  4419. $orientation = ( $thumb_height > $thumb_width ) ? 'portrait' : 'landscape';
  4420.  
  4421. if ( '' !== $thumb_src ) : ?>
  4422. <div class="et_pb_portfolio_image <?php echo esc_attr( $orientation ); ?>">
  4423. <a href="<?php the_permalink(); ?>">
  4424. <img src="<?php echo esc_attr( $thumb_src ); ?>" alt="<?php echo esc_attr( get_the_title() ); ?>"/>
  4425. <div class="meta">
  4426. <span class="et_overlay"></span>
  4427.  
  4428. <?php if ( 'on' === $show_title ) : ?>
  4429. <h3><?php the_title(); ?></h3>
  4430. <?php endif; ?>
  4431.  
  4432. <?php if ( 'on' === $show_date ) : ?>
  4433. <p class="post-meta"><?php echo get_the_date(); ?></p>
  4434. <?php endif; ?>
  4435. </div>
  4436. </a>
  4437. </div>
  4438. <?php endif; ?>
  4439. </div>
  4440. <?php
  4441. }
  4442. }
  4443.  
  4444. wp_reset_postdata();
  4445.  
  4446. $posts = ob_get_clean();
  4447.  
  4448. $class = " et_pb_bg_layout_{$background_layout}";
  4449.  
  4450. $output = sprintf(
  4451. '<div%4$s class="et_pb_fullwidth_portfolio %1$s%3$s%5$s" data-auto-rotate="%6$s" data-auto-rotate-speed="%7$s">
  4452. %8$s
  4453. <div class="et_pb_portfolio_items clearfix" data-columns="">
  4454. %2$s
  4455. </div><!-- .et_pb_portfolio_items -->
  4456. </div> <!-- .et_pb_fullwidth_portfolio -->',
  4457. ( 'on' === $fullwidth ? 'et_pb_fullwidth_portfolio_carousel' : 'et_pb_fullwidth_portfolio_grid clearfix' ),
  4458. $posts,
  4459. esc_attr( $class ),
  4460. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4461. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  4462. ( '' !== $auto && in_array( $auto, array('on', 'off') ) ? esc_attr( $auto ) : 'off' ),
  4463. ( '' !== $auto_speed && is_numeric( $auto_speed ) ? esc_attr( $auto_speed ) : '7000' ),
  4464. ( '' !== $title ? sprintf( '<h2>%s</h2>', esc_html( $title ) ) : '' )
  4465. );
  4466.  
  4467. return $output;
  4468. }
  4469.  
  4470. add_shortcode( 'et_pb_pricing_tables', 'et_pb_pricing_tables' );
  4471. function et_pb_pricing_tables( $atts, $content = null ) {
  4472. extract( shortcode_atts( array(
  4473. 'module_id' => '',
  4474. 'module_class' => '',
  4475. ), $atts
  4476. ) );
  4477.  
  4478. global $et_pb_pricing_tables_num;
  4479.  
  4480. $et_pb_pricing_tables_num = 0;
  4481.  
  4482. $content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  4483.  
  4484. $output = sprintf(
  4485. '<div%3$s class="et_pb_pricing clearfix%2$s%4$s">
  4486. %1$s
  4487. </div>',
  4488. $content,
  4489. esc_attr( " et_pb_pricing_{$et_pb_pricing_tables_num}" ),
  4490. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4491. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  4492. );
  4493.  
  4494. return $output;
  4495. }
  4496.  
  4497. add_shortcode( 'et_pb_pricing_table', 'et_pb_pricing_table' );
  4498. function et_pb_pricing_table( $atts, $content = null ) {
  4499. global $et_pb_pricing_tables_num;
  4500.  
  4501. extract( shortcode_atts( array(
  4502. 'featured' => 'off',
  4503. 'title' => '',
  4504. 'subtitle' => '',
  4505. 'currency' => '',
  4506. 'per' => '',
  4507. 'sum' => '',
  4508. 'button_url' => '',
  4509. 'button_text' => '',
  4510. ), $atts
  4511. ) );
  4512.  
  4513. $et_pb_pricing_tables_num++;
  4514.  
  4515. if ( '' !== $button_url && '' !== $button_text )
  4516. $button_text = sprintf( '<a class="et_pb_pricing_table_button" href="%1$s">%2$s</a>',
  4517. esc_url( $button_url ),
  4518. esc_html( $button_text )
  4519. );
  4520.  
  4521. $output = sprintf(
  4522. '<div class="et_pb_pricing_table%1$s">
  4523. <div class="et_pb_pricing_heading">
  4524. %2$s
  4525. %3$s
  4526. </div> <!-- .et_pb_pricing_heading -->
  4527. <div class="et_pb_pricing_content_top">
  4528. <span class="et_pb_et_price">%6$s%7$s%8$s</span>
  4529. </div> <!-- .et_pb_pricing_content_top -->
  4530. <div class="et_pb_pricing_content">
  4531. <ul class="et_pb_pricing">
  4532. %4$s
  4533. </ul>
  4534. </div> <!-- .et_pb_pricing_content -->
  4535. %5$s
  4536. </div>',
  4537. ( 'off' !== $featured ? ' et_pb_featured_table' : '' ),
  4538. ( '' !== $title ? sprintf( '<h2 class="et_pb_pricing_title">%1$s</h2>', esc_html( $title ) ) : '' ),
  4539. ( '' !== $subtitle ? sprintf( '<span class="et_pb_best_value">%1$s</span>', esc_html( $subtitle ) ) : '' ),
  4540. do_shortcode( et_pb_fix_shortcodes( et_pb_extract_items( $content ) ) ),
  4541. $button_text,
  4542. ( '' !== $currency ? sprintf( '<span class="et_pb_dollar_sign">%1$s</span>', esc_html( $currency ) ) : '' ),
  4543. ( '' !== $sum ? sprintf( '<span class="et_pb_sum">%1$s</span>', esc_html( $sum ) ) : '' ),
  4544. ( '' !== $per ? sprintf( '/%1$s', esc_html( $per ) ) : '' )
  4545. );
  4546.  
  4547. return $output;
  4548. }
  4549.  
  4550. function et_pb_extract_items( $content ) {
  4551. $output = $first_character = '';
  4552.  
  4553. $lines = explode( "\n", str_replace( array( '<p>', '</p>', '<br />' ), '', $content ) );
  4554.  
  4555. foreach ( $lines as $line ) {
  4556. $line = trim( $line );
  4557.  
  4558. if ( '' === $line ) continue;
  4559.  
  4560. $first_character = $line[0];
  4561.  
  4562. if ( in_array( $first_character, array( '-', '+' ) ) )
  4563. $line = trim( substr( $line, 1 ) );
  4564.  
  4565. $output .= sprintf( '[et_pb_pricing_item available="%2$s"]%1$s[/et_pb_pricing_item]',
  4566. $line,
  4567. ( '-' === $first_character ? 'off' : 'on' )
  4568. );
  4569. }
  4570.  
  4571. return $output;
  4572. }
  4573.  
  4574. add_shortcode( 'et_pb_pricing_item', 'et_pb_pricing_item' );
  4575. function et_pb_pricing_item( $atts, $content = null ) {
  4576. extract( shortcode_atts( array(
  4577. 'available' => 'on',
  4578. ), $atts
  4579. ) );
  4580.  
  4581. $output = sprintf( '<li%2$s>%1$s</li>',
  4582. do_shortcode( et_pb_fix_shortcodes( $content ) ),
  4583. ( 'on' !== $available ? ' class="et_pb_not_available"' : '' )
  4584. );
  4585.  
  4586. return $output;
  4587. }
  4588.  
  4589. add_shortcode( 'et_pb_contact_form', 'et_pb_contact_form' );
  4590. function et_pb_contact_form( $atts, $content = null ) {
  4591. global $et_pb_contact_form_num;
  4592.  
  4593. extract( shortcode_atts( array(
  4594. 'module_id' => '',
  4595. 'module_class' => '',
  4596. 'captcha' => 'on',
  4597. 'email' => '',
  4598. 'title' => '',
  4599. ), $atts
  4600. ) );
  4601.  
  4602. $et_error_message = '';
  4603. $et_contact_error = false;
  4604. $contact_email = isset( $_POST['et_pb_contact_email'] ) ? sanitize_email( $_POST['et_pb_contact_email'] ) : '';
  4605.  
  4606. if ( isset( $_POST['et_pb_contactform_submit'] ) ) {
  4607. if ( 'on' === $captcha && ( ! isset( $_POST['et_pb_contact_captcha'] ) || empty( $_POST['et_pb_contact_captcha'] ) ) ) {
  4608. $et_error_message .= sprintf( '<p>%1$s</p>', esc_html__( 'Make sure you entered the captcha.', 'Divi' ) );
  4609. $et_contact_error = true;
  4610. } else if ( 'on' === $captcha && ( $_POST['et_pb_contact_captcha'] <> ( $_SESSION['et_pb_first_digit'] + $_SESSION['et_pb_second_digit'] ) ) ) {
  4611. $et_error_message .= sprintf( '<p>%1$s</p>', esc_html__( 'You entered the wrong number in captcha.', 'Divi' ) );
  4612.  
  4613. unset( $_SESSION['et_pb_first_digit'] );
  4614. unset( $_SESSION['et_pb_second_digit'] );
  4615.  
  4616. $et_contact_error = true;
  4617. } else if ( empty( $_POST['et_pb_contact_name'] ) || empty( $contact_email ) || empty( $_POST['et_pb_contact_message'] ) ) {
  4618. $et_error_message .= sprintf( '<p>%1$s</p>', esc_html__( 'Make sure you fill all fields.', 'Divi' ) );
  4619. $et_contact_error = true;
  4620. }
  4621.  
  4622. if ( ! is_email( $contact_email ) ) {
  4623. $et_error_message .= sprintf( '<p>%1$s</p>', esc_html__( 'Invalid Email.', 'Divi' ) );
  4624. $et_contact_error = true;
  4625. }
  4626. } else {
  4627. $et_contact_error = true;
  4628. if ( isset( $_SESSION['et_pb_first_digit'] ) )
  4629. unset( $_SESSION['et_pb_first_digit'] );
  4630. if ( isset( $_SESSION['et_pb_second_digit'] ) )
  4631. unset( $_SESSION['et_pb_second_digit'] );
  4632. }
  4633.  
  4634. if ( ! isset( $_SESSION['et_pb_first_digit'] ) )
  4635. $_SESSION['et_pb_first_digit'] = $et_pb_first_digit = rand(1, 15);
  4636. else
  4637. $et_pb_first_digit = $_SESSION['et_pb_first_digit'];
  4638.  
  4639. if ( ! isset( $_SESSION['et_pb_second_digit'] ) )
  4640. $_SESSION['et_pb_second_digit'] = $et_pb_second_digit = rand(1, 15);
  4641. else
  4642. $et_pb_second_digit = $_SESSION['et_pb_second_digit'];
  4643.  
  4644. if ( ! $et_contact_error && isset( $_POST['_wpnonce-et-pb-contact-form-submitted'] ) && wp_verify_nonce( $_POST['_wpnonce-et-pb-contact-form-submitted'], 'et-pb-contact-form-submit' ) ) {
  4645. $et_email_to = '' !== $email
  4646. ? $email
  4647. : get_site_option( 'admin_email' );
  4648.  
  4649. $et_site_name = get_option( 'blogname' );
  4650.  
  4651. $contact_name = stripslashes( sanitize_text_field( $_POST['et_pb_contact_name'] ) );
  4652.  
  4653. $headers[] = "From: \"{$contact_name}\" <{$contact_email}>";
  4654. $headers[] = "Reply-To: <{$contact_email}>";
  4655.  
  4656. wp_mail( apply_filters( 'et_contact_page_email_to', $et_email_to ),
  4657. sprintf( __( 'New Message From %1$s%2$s', 'Divi' ),
  4658. sanitize_text_field( $et_site_name ),
  4659. ( '' !== $title ? sprintf( _x( ' - %s', 'contact form title separator', 'Divi' ), sanitize_text_field( $title ) ) : '' )
  4660. ), stripslashes( wp_strip_all_tags( $_POST['et_pb_contact_message'] ) ), apply_filters( 'et_contact_page_headers', $headers, $contact_name, $contact_email ) );
  4661.  
  4662. $et_error_message = sprintf( '<p>%1$s</p>', esc_html__( 'Thanks for contacting us', 'Divi' ) );
  4663. }
  4664.  
  4665. $form = '';
  4666.  
  4667. $name_label = __( 'Name', 'Divi' );
  4668. $email_label = __( 'Email Address', 'Divi' );
  4669. $message_label = __( 'Message', 'Divi' );
  4670.  
  4671. $et_pb_contact_form_num = ! isset( $et_pb_contact_form_num ) ? 1 : $et_pb_contact_form_num++;
  4672.  
  4673. $et_pb_captcha = sprintf( '
  4674. <div class="et_pb_contact_right">
  4675. <p class="clearfix">
  4676. %1$s = <input type="text" size="2" class="input et_pb_contact_captcha" value="" name="et_pb_contact_captcha">
  4677. </p>
  4678. </div> <!-- .et_pb_contact_right -->',
  4679. sprintf( '%1$s + %2$s', esc_html( $et_pb_first_digit ), esc_html( $et_pb_second_digit ) )
  4680. );
  4681.  
  4682. if ( $et_contact_error )
  4683. $form = sprintf( '
  4684. <div class="et_pb_contact">
  4685. <div class="et-pb-contact-message">%11$s</div>
  4686.  
  4687. <form class="et_pb_contact_form clearfix" method="post" action="%1$s">
  4688. <div class="et_pb_contact_left">
  4689. <p class="clearfix">
  4690. <label class="et_pb_contact_form_label">%2$s</label>
  4691. <input type="text" class="input et_pb_contact_name" value="%3$s" name="et_pb_contact_name">
  4692. </p>
  4693. <p class="clearfix">
  4694. <label class="et_pb_contact_form_label">%4$s</label>
  4695. <input type="text" class="input et_pb_contact_email" value="%5$s" name="et_pb_contact_email">
  4696. </p>
  4697. </div> <!-- .et_pb_contact_left -->
  4698.  
  4699. <div class="clear"></div>
  4700. <p class="clearfix">
  4701. <label class="et_pb_contact_form_label">%7$s</label>
  4702. <textarea name="et_pb_contact_message" class="et_pb_contact_message input">%8$s</textarea>
  4703. </p>
  4704.  
  4705. <input type="hidden" value="et_contact_proccess" name="et_pb_contactform_submit">
  4706.  
  4707. <input type="submit" value="%9$s" class="et_pb_contact_submit">
  4708.  
  4709. %6$s
  4710.  
  4711. %10$s
  4712. </form>
  4713. </div> <!-- .et_pb_contact -->',
  4714. esc_url( get_permalink( get_the_ID() ) ),
  4715. $name_label,
  4716. ( isset( $_POST['et_pb_contact_name'] ) ? esc_attr( $_POST['et_pb_contact_name'] ) : $name_label ),
  4717. $email_label,
  4718. ( isset( $_POST['et_pb_contact_email'] ) ? esc_attr( $_POST['et_pb_contact_email'] ) : $email_label ),
  4719. ( 'on' === $captcha ? $et_pb_captcha : '' ),
  4720. $message_label,
  4721. ( isset( $_POST['et_pb_contact_message'] ) ? esc_attr( $_POST['et_pb_contact_message'] ) : $message_label ),
  4722. __( 'Submit', 'Divi' ),
  4723. wp_nonce_field( 'et-pb-contact-form-submit', '_wpnonce-et-pb-contact-form-submitted', true, false ),
  4724. $et_error_message
  4725. );
  4726.  
  4727. $output = sprintf( '
  4728. <div id="%4$s" class="et_pb_contact_form_container clearfix%5$s">
  4729. %1$s
  4730. %2$s
  4731. %3$s
  4732. </div> <!-- .et_pb_contact_form_container -->
  4733. ',
  4734. ( '' !== $title ? sprintf( '<h1 class="et_pb_contact_main_title">%1$s</h1>', esc_html( $title ) ) : '' ),
  4735. ( '' !== $et_error_message ? sprintf( '<div class="et-pb-contact-message">%1$s</div>', $et_error_message ) : '' ),
  4736. $form,
  4737. ( '' !== $module_id
  4738. ? esc_attr( $module_id )
  4739. : esc_attr( 'et_pb_contact_form_' . $et_pb_contact_form_num )
  4740. ),
  4741. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  4742. );
  4743.  
  4744. return $output;
  4745. }
  4746.  
  4747. add_shortcode( 'et_pb_divider', 'et_pb_divider' );
  4748. function et_pb_divider( $atts, $content = null ) {
  4749. extract( shortcode_atts( array(
  4750. 'module_id' => '',
  4751. 'module_class' => '',
  4752. 'color' => '',
  4753. 'show_divider' => 'off',
  4754. 'height' => '',
  4755. ), $atts
  4756. ) );
  4757.  
  4758. $style = '';
  4759.  
  4760. if ( '' !== $color && 'on' === $show_divider )
  4761. $style .= sprintf( 'border-color: %s;',
  4762. esc_attr( $color )
  4763. );
  4764.  
  4765. if ( '' !== $height )
  4766. $style .= sprintf( 'height:%spx;',
  4767. esc_attr( $height )
  4768. );
  4769.  
  4770. $style = '' !== $style ? " style='{$style}'" : '';
  4771.  
  4772. $output = sprintf(
  4773. '<hr%3$s class="et_pb_space%1$s%4$s"%2$s />',
  4774. ( 'on' === $show_divider ? ' et_pb_divider' : '' ),
  4775. $style,
  4776. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4777. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  4778. );
  4779.  
  4780. return $output;
  4781. }
  4782.  
  4783. add_shortcode( 'et_pb_shop', 'et_pb_shop' );
  4784. function et_pb_shop( $atts, $content = null ) {
  4785. extract( shortcode_atts( array(
  4786. 'module_id' => '',
  4787. 'module_class' => '',
  4788. 'type' => 'recent',
  4789. 'posts_number' => '12',
  4790. 'orderby' => 'menu_order',
  4791. 'columns' => '4',
  4792. ), $atts
  4793. ) );
  4794.  
  4795. $woocommerce_shortcodes_types = array(
  4796. 'recent' => 'recent_products',
  4797. 'featured' => 'featured_products',
  4798. 'sale' => 'sale_products',
  4799. 'best_selling' => 'best_selling_products',
  4800. 'top_rated' => 'top_rated_products',
  4801. );
  4802.  
  4803. $output = sprintf(
  4804. '<div%2$s class="et_pb_shop%3$s">
  4805. %1$s
  4806. </div>',
  4807. do_shortcode(
  4808. sprintf( '[%1$s per_page="%2$s" orderby="%3$s" columns="%4$s"]',
  4809. esc_html( $woocommerce_shortcodes_types[$type] ),
  4810. esc_attr( $posts_number ),
  4811. esc_attr( $orderby ),
  4812. esc_attr( $columns )
  4813. )
  4814. ),
  4815. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4816. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  4817. );
  4818.  
  4819. return $output;
  4820. }
  4821.  
  4822. add_shortcode( 'et_pb_fullwidth_header', 'et_pb_fullwidth_header' );
  4823. function et_pb_fullwidth_header( $atts, $content = null ) {
  4824. extract( shortcode_atts( array(
  4825. 'module_id' => '',
  4826. 'module_class' => '',
  4827. 'title' => '',
  4828. 'subhead' => '',
  4829. 'background_layout' => 'light',
  4830. 'text_orientation' => 'left',
  4831. ), $atts
  4832. ) );
  4833.  
  4834. if ( is_rtl() && 'left' === $text_orientation ) {
  4835. $text_orientation = 'right';
  4836. }
  4837.  
  4838. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  4839.  
  4840. $output = sprintf(
  4841. '<section%4$s class="et_pb_fullwidth_header%3$s%5$s">
  4842. <div class="et_pb_row">
  4843. <h1>%1$s</h1>
  4844. %2$s
  4845. </div>
  4846. </section>',
  4847. $title,
  4848. ( $subhead ? sprintf( '<p class="et_pb_fullwidth_header_subhead">%1$s</p>', $subhead ) : '' ),
  4849. esc_attr( $class ),
  4850. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4851. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' )
  4852. );
  4853.  
  4854. return $output;
  4855. }
  4856.  
  4857. add_shortcode( 'et_pb_fullwidth_menu', 'et_pb_fullwidth_menu' );
  4858. function et_pb_fullwidth_menu( $atts, $content = null ) {
  4859. extract( shortcode_atts( array(
  4860. 'module_id' => '',
  4861. 'module_class' => '',
  4862. 'background_color' => '',
  4863. 'background_layout' => 'light',
  4864. 'text_orientation' => 'left',
  4865. 'menu_id' => '',
  4866. 'submenu_direction' => 'downwards',
  4867. ), $atts
  4868. ) );
  4869.  
  4870. if ( is_rtl() && 'left' === $text_orientation ) {
  4871. $text_orientation = 'right';
  4872. }
  4873.  
  4874. $style = '';
  4875.  
  4876. if ( '' !== $background_color ) {
  4877. $style .= sprintf( ' style="background-color: %s;"',
  4878. esc_attr( $background_color )
  4879. );
  4880. }
  4881.  
  4882. $class = " et_pb_bg_layout_{$background_layout} et_pb_text_align_{$text_orientation}";
  4883.  
  4884. $menu = '<nav class="fullwidth-menu-nav">';
  4885. $menuClass = 'fullwidth-menu nav';
  4886. if ( 'on' == et_get_option( 'divi_disable_toptier' ) ) {
  4887. $menuClass .= ' et_disable_top_tier';
  4888. }
  4889. $menuClass .= ( '' !== $submenu_direction ? sprintf( ' %s', esc_attr( $submenu_direction ) ) : '' );
  4890.  
  4891. $primaryNav = '';
  4892.  
  4893. $menu_args = array(
  4894. 'theme_location' => 'primary-menu',
  4895. 'container' => '',
  4896. 'fallback_cb' => '',
  4897. 'menu_class' => $menuClass,
  4898. 'menu_id' => '',
  4899. 'echo' => false,
  4900. );
  4901.  
  4902. if ( '' !== $menu_id ) {
  4903. $menu_args['menu'] = (int) $menu_id;
  4904. }
  4905.  
  4906. $primaryNav = wp_nav_menu( apply_filters( 'et_fullwidth_menu_args', $menu_args ) );
  4907.  
  4908. if ( '' == $primaryNav ) {
  4909. $menu .= sprintf(
  4910. '<ul class="%1$s">
  4911. %2$s
  4912. </ul>',
  4913. esc_attr( $menuClass ),
  4914. ( 'on' === et_get_option( 'divi_home_link' )
  4915. ? sprintf( '<li%1$s><a href="%2$s">%3$s</a></li>',
  4916. ( is_home() ? ' class="current_page_item"' : '' ),
  4917. esc_url( home_url( '/' ) ),
  4918. esc_html_e( 'Home', 'Divi' )
  4919. )
  4920. : ''
  4921. )
  4922. );
  4923.  
  4924. ob_start();
  4925.  
  4926. show_page_menu( $menuClass, false, false );
  4927. show_categories_menu( $menuClass, false );
  4928.  
  4929. $menu .= ob_get_contents();
  4930.  
  4931. ob_end_clean();
  4932. } else {
  4933. $menu .= $primaryNav;
  4934. }
  4935.  
  4936. $menu .= '</nav>';
  4937.  
  4938. $output = sprintf(
  4939. '<div%4$s class="et_pb_fullwidth_menu%3$s%5$s"%2$s%6$s>
  4940. <div class="et_pb_row clearfix">
  4941. %1$s
  4942. <div class="et_mobile_nav_menu">
  4943. <a href="#" class="mobile_nav closed">
  4944. <span class="mobile_menu_bar"></span>
  4945. </a>
  4946. </div>
  4947. </div>
  4948. </div>',
  4949. $menu,
  4950. $style,
  4951. esc_attr( $class ),
  4952. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4953. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  4954. ( '' !== $style ? sprintf( ' data-bg_color=%1$s', esc_attr( $background_color ) ) : '' )
  4955. );
  4956.  
  4957. return $output;
  4958. }
  4959.  
  4960. add_shortcode( 'et_pb_fullwidth_map', 'et_pb_map' );
  4961. add_shortcode( 'et_pb_map', 'et_pb_map' );
  4962. function et_pb_map( $atts, $content = '' ) {
  4963. extract( shortcode_atts( array(
  4964. 'module_id' => '',
  4965. 'module_class' => '',
  4966. 'address_lat' => '',
  4967. 'address_lng' => '',
  4968. 'zoom_level' => 18,
  4969. 'mouse_wheel' => 'on',
  4970. ), $atts
  4971. ) );
  4972.  
  4973. wp_enqueue_script( 'google-maps-api' );
  4974.  
  4975. $all_pins_content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  4976.  
  4977. $output = sprintf(
  4978. '<div%5$s class="et_pb_map_container%6$s">
  4979. <div class="et_pb_map" data-center-lat="%1$s" data-center-lng="%2$s" data-zoom="%3$d" data-mouse-wheel="%7$s"></div>
  4980. %4$s
  4981. </div>',
  4982. esc_attr( $address_lat ),
  4983. esc_attr( $address_lng ),
  4984. esc_attr( $zoom_level ),
  4985. $all_pins_content,
  4986. ( '' !== $module_id ? sprintf( ' id="%1$s"', esc_attr( $module_id ) ) : '' ),
  4987. ( '' !== $module_class ? sprintf( ' %1$s', esc_attr( $module_class ) ) : '' ),
  4988. esc_attr( $mouse_wheel )
  4989. );
  4990.  
  4991. return $output;
  4992. }
  4993.  
  4994. add_shortcode( 'et_pb_map_pin', 'et_pb_map_pin' );
  4995. function et_pb_map_pin( $atts, $content = null ) {
  4996. global $et_pb_tab_titles;
  4997.  
  4998. extract( shortcode_atts( array(
  4999. 'title' => '',
  5000. 'pin_address_lat' => '',
  5001. 'pin_address_lng' => '',
  5002. ), $atts
  5003. ) );
  5004.  
  5005. $content = do_shortcode( et_pb_fix_shortcodes( $content ) );
  5006.  
  5007. $output = sprintf(
  5008. '<div class="et_pb_map_pin" data-lat="%1$s" data-lng="%2$s" data-title="%3$s">
  5009. %4$s
  5010. </div>',
  5011. esc_attr( $pin_address_lat ),
  5012. esc_attr( $pin_address_lng ),
  5013. esc_html( $title ),
  5014. ( '' != $content ? sprintf( '<div class="infowindow">%1$s</div>', $content ) : '' )
  5015. );
  5016.  
  5017. return $output;
  5018. }
  5019.  
  5020. function divi_bootstrap_scripts() {
  5021. wp_enqueue_style( 'divi-bootstrap-css', get_stylesheet_uri().'bootstrap/css/bootstrap.css' );
  5022. wp_enqueue_script( 'divi-bootstrap-js', get_template_directory_uri() . 'bootstrap/js/bootstrap.js');
  5023. }
  5024.  
  5025. add_action( 'wp_enqueue_scripts', 'divi_bootstrap_scripts' );
RAW Paste Data