Advertisement
Guest User

Untitled

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