Adding popup newsletter code to the functions.php

So I have signed up with Constant Contact mail & newsletter and I am trying to add the universal code to activate the popup signup form I made and they normally require you to put their code in the footer.php, but on the Pro I want to add it to the functions.php file of my child theme correct?

I tried this:

[code]<?php
// Exit if accessed directly
if ( !defined( ‘ABSPATH’ ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( ‘child_theme_configurator_css’ ) ):
function child_theme_configurator_css() {
wp_enqueue_style( ‘chld_thm_cfg_child’, trailingslashit( get_stylesheet_directory_uri() ) . ‘style.css’, array( ‘x-stack’,‘x-cranium-migration’,‘x-woocommerce’ ) );
}
endif;
add_action( ‘wp_enqueue_scripts’, ‘child_theme_configurator_css’ );
// Add Social Sharing after the single post content // =============================================================================
function x_add_social_sharing ( $content ) {
if ( is_single() ) {
echo do_shortcode(’[x_share title=“Share this Post” facebook=“true” twitter=“true” google_plus=“true” linkedin=“true” pinterest=“true” reddit=“true” email=“true”]’);
}
}
add_action(‘x_before_the_content_end’, ‘x_add_social_sharing’);
// END ENQUEUE PARENT ACTION
//
//

[/code]

And also this:

[code]<?php
// Exit if accessed directly
if ( !defined( ‘ABSPATH’ ) ) exit;
// BEGIN ENQUEUE PARENT ACTION
// AUTO GENERATED - Do not modify or remove comment markers above or below:
if ( !function_exists( ‘child_theme_configurator_css’ ) ):
function child_theme_configurator_css() {
wp_enqueue_style( ‘chld_thm_cfg_child’, trailingslashit( get_stylesheet_directory_uri() ) . ‘style.css’, array( ‘x-stack’,‘x-cranium-migration’,‘x-woocommerce’ ) );
}
endif;
add_action( ‘wp_enqueue_scripts’, ‘child_theme_configurator_css’ );
// Add Social Sharing after the single post content // =============================================================================
function x_add_social_sharing ( $content ) {
if ( is_single() ) {
echo do_shortcode(’[x_share title=“Share this Post” facebook=“true” twitter=“true” google_plus=“true” linkedin=“true” pinterest=“true” reddit=“true” email=“true”]’);
}
}
add_action(‘x_before_the_content_end’, ‘x_add_social_sharing’);

// END ENQUEUE PARENT ACTION[/code]

And both ways gave me the following error:

Your PHP code changes were rolled back due to an error on line 22 of file wp-content/themes/pro-child/functions.php. Please fix and try saving again.

syntax error, unexpected ‘<’, expecting end of file

So what am I doing wrong?

Thanks.

Hi,

Thanks for writing in! Regretfully, this particular request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your integration of a third party script. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. We do have an in-house custom development team that offer paid services, who may be able to assist. They can be contacted at pinnacle@theme.co if this is of interest to you. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.

Thank you for your understanding.

Constant contact wasn’t very helpful on this problem - all I need to know is if I’m adding their line of code correctly to the functions.php file - I’m not familiar with php so I don’t know how to add it correctly, my two attempts that I listed above were both unsuccessful.

Hello There,

To resolve your issue, please remove this block:

<!-- Begin Constant Contact Active Forms -->
<script> var _ctct_m = "b7a78879626ca47dbc92142cf38345ce"; </script>
<script id="signupScript" src="//static.ctctcdn.com/js/signup-form-widget/current/signup-form-widget.min.js" async defer></script>
<!-- End Constant Contact Active Forms -->
// END ENQUEUE PARENT ACTION

You will need to replace it using this code instead:

function add_ccform() { ?>

  <!-- Begin Constant Contact Active Forms -->
  <script> var _ctct_m = "b7a78879626ca47dbc92142cf38345ce"; </script>
  <script id="signupScript" src="//static.ctctcdn.com/js/signup-form-widget/current/signup-form-widget.min.js" async defer></script>
  <!-- End Constant Contact Active Forms -->
  <?php // END ENQUEUE PARENT ACTION ?>


<?php }
add_action('wp_footer', 'add_ccform');

We would loved to know if this has work for you. Thank you.

hmm this is weird, now my child theme functions.php was totally blank inside of my WP dashboard editor?

I tried adding the code you suggested and got this error:

[code]Your PHP code changes were rolled back due to an error on line 10 of file wp-content/themes/pro-child/functions.php. Please fix and try saving again.

syntax error, unexpected ‘}’, expecting end of file[/code]

I wonder if my functions.php file got corrupted from me trying to edit it before and for some reason is now blank?

Should I just make a new Pro child-theme?

Hi There,

If you’re getting a blank page, you can enable WP_DEBUG mode by editing your wp-config.php file as follows which you will be able to locate inside the root of your WordPress installation.

define('WP_DEBUG', true);

Then re-visit your page and you will see a PHP error message which will help you to identify the issue.

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.