Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.04 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Enqueues Divi's stylesheet. Divi will enqueue this child theme's stylesheet
  5.  * on its own (see parent functions.php:249).
  6.  * @return [type] [description]
  7.  */
  8. function theme_enqueue_styles() {
  9.  
  10.     wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
  11.  
  12. }
  13. add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
  14.  
  15.  
  16.  
  17. // JS Cookie script to retrieve values from cookie and push to custom fields :)
  18. // script provided by MemberFix! (https://memberfix.rocks)
  19.  
  20. function js_cookie() {
  21.     wp_enqueue_script( 'js-cookie', "https://cdn.jsdelivr.net/npm/js-cookie@2/src/js.cookie.min.js", false );
  22. }
  23. add_action( 'wp_enqueue_scripts', 'js_cookie' );
  24.  
  25. function custom_cookie_script() { ?>
  26.     <script type="text/javascript">
  27.         jQuery('input[id^="mm_custom_field_"]').each(function( i, val ) {
  28.             var id = jQuery(this).attr('id').match(/\d+/)[0];
  29.             if (typeof Cookies.get('cf_'+id) != 'undefined' ) {
  30.                 var target = document.getElementsByName('mm_custom_field_'+id)[ 0 ];
  31.                 target.value = Cookies.get('cf_'+id);
  32.             }
  33.         });
  34.     </script>
  35.     <?php
  36. }
  37. add_action( 'wp_footer', 'custom_cookie_script' );
  38.  
  39. // End JS Cookie
  40.  
  41.  
  42.  
  43. function gallery_size_h($height) {
  44.     return '600';
  45. }
  46. add_filter( 'et_pb_blog_image_height', 'gallery_size_h' );
  47.  
  48. function gallery_size_w($width) {
  49.     return '300';
  50. }
  51. add_filter( 'et_pb_blog_image_width', 'gallery_size_w' );
  52.  
  53. if ( ! function_exists( 'et_get_original_footer_credits' ) ) :
  54.  
  55.     function et_get_original_footer_credits() {
  56.         return sprintf( __( 'Designed by %1$s | Powered by %2$s', 'Divi' ), '<a href="http://www.socialactive.com" title="Internet Marketing Agency">SocialActive</a>', '<a href="https://www.socialactive.gr">Awesome CMS</a>' );
  57.     }
  58.    
  59. endif;
  60.  
  61. /*
  62.  * Prepares the settings for Intercom's script.
  63.  */
  64. function theme_prepare_intercom_settings() {
  65.  
  66.     // The app_id is the only setting required for non-members.
  67.     $intercom_settings = array( 'app_id' => 'rc8ci07z' );
  68.  
  69.     if ( function_exists( 'mm_member_decision' ) && mm_member_decision( array( 'isMember' => 'true' ) ) ) {
  70.  
  71.         $intercom_settings['name'] = mm_member_data( array( 'name' => 'firstName' ) ) . ' ' . mm_member_data( array( 'name' => 'lastName' ) );
  72.         $intercom_settings['email'] = mm_member_data( array( 'name' => 'email' ) );
  73.         $intercom_settings['created_at'] = mm_member_data( array( 'name' => 'registrationDate' ) );
  74.         $intercom_settings['total_spend'] = mm_order_data(array('name'=>'total' ) );
  75.         $intercom_settings['phone'] = mm_order_data(array('name'=>'phone' ) );
  76.         $intercom_settings['confirm_time_at'] = mm_order_data(array('name'=>'registrationDate' ) );
  77.         $intercom_settings['statusChangedDate'] = mm_order_data(array('name'=>'statusChangedDate' ) );
  78.         $intercom_settings['Membership_Expiration'] = mm_order_data(array('name'=>'expirationDate' ) );
  79.         $intercom_settings['days_as_member'] = mm_order_data(array('name'=>'daysAsMember' ) );
  80.         $intercom_settings['plan'] = mm_order_data(array('name'=>'membershipId' ) );
  81.         $intercom_settings['status_name'] = mm_order_data(array('name'=>'statusName' ) );
  82.  
  83.     }
  84.  
  85.     ?>
  86.  
  87.     <!-- Intercom Settings Start -->
  88.     <script type = "text/javascript">
  89.         window.intercomSettings = <?php echo json_encode( $intercom_settings ); ?>
  90.     </script>
  91.     <!-- Intercom Settings End -->
  92.  
  93.     <script>(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/rc8ci07z';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})()</script>
  94.  
  95.     <?php
  96.  
  97. }
  98. add_action( 'wp_footer', 'theme_prepare_intercom_settings' );
  99.  
  100. function theme_print_gtm_tag() {
  101.  
  102.     if ( function_exists( 'gtm4wp_the_gtm_tag' ) ) {
  103.         gtm4wp_the_gtm_tag();
  104.     }
  105.  
  106. }
  107. add_action( 'wp_footer', 'theme_print_gtm_tag' );
  108.  
  109. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement