inboundnow / retired-cta

Create Calls to Action for your WordPress site. Monitor and improve conversion rates, run A/B split tests, customize your own CTA templates and more
http://www.inboundnow.com/cta/
1 stars 3 forks source link

PHP errors #29

Closed DavidWells closed 10 years ago

DavidWells commented 10 years ago

Seeing some PHP errors with new JSON api tests I'm running.

Notice: Undefined property: CallsToAction::$disable_ajax in /Users/davidgregorywells/Dropbox/Sites/Local-Git/wp-content/plugins/cta/modules/module.calls-to-action.php on line 1008

Warning: Cannot modify header information - headers already sent by (output started at /Users/davidgregorywells/Dropbox/Sites/Local-Git/wp-content/plugins/cta/modules/module.calls-to-action.php:755) in <

The problem is here: https://github.com/inboundnow/cta/blob/master/modules/module.calls-to-action.php#L751-L765

We are echoing out data in the function but instead need to return the css/js to the call to action and echo it out elsewhere (or the cta is already echoing out its entire instance somewhere)

So the echos in the 'load_custom_js_css' function need to be returns but I'm not sure exactly where the rest of the CTA instance is being echoed out.

Does this make sense? I believe http://www.inboundnow.com/support/topic/cta-install-failure/page/2/ is related

atwellpub commented 10 years ago

What kind of CTA is being rendered? Static Widget, Dynamic, Shortcode?

DavidWells commented 10 years ago

None this is firing on random backend pages and on the json API callback.

We are echoing data and its breaking outputs on backend functionality.

We need to return instead of echo the data and perhaps wrap these functions so they only call on the frontend

atwellpub commented 10 years ago

But https://github.com/inboundnow/cta/blob/master/modules/module.calls-to-action.php#L1008 should only run if there is a cta shortcode being executed. Check the back trail. I can only find one place calling the parent function and that's in the shortcode render.

DavidWells commented 10 years ago

errors thrown elswehere

The errors are being thrown in the json callback and in the rss feed. (http://glocal.dev/feed/)

DavidWells commented 10 years ago

In rss feed:

<item>
<title>Blank test</title>
<link>http://glocal.dev/blank-test/</link>
<comments>http://glocal.dev/blank-test/#respond</comments>
<pubDate>Mon, 10 Mar 2014 21:37:14 +0000</pubDate>
<dc:creator>
<![CDATA[ David Wells ]]>
</dc:creator>
<category>
<![CDATA[ Uncategorized ]]>
</category>
<guid isPermaLink="false">http://glocal.dev/?p=2443</guid>
<description>
<![CDATA[ ]]>
</description>
<style type="text/css" id="wp_cta_css_custom_2440_0" class="wp_cta_css_2440
"></style>
<script type="text/javascript"
id="wp_cta_js_custom">jQuery(document).ready(function($)
{ });</script>
<script>
jQuery(document).ready(function($) { wp_cta_load_variation( '2440' , '
<br/>
<b>Notice</b>
: Undefined property: CallsToAction::$disable_ajax in
<b>
/Users/davidgregorywells/Dropbox/Sites/Local-Git/wp-content/plugins/cta/modules/module.calls-to-action.php
</b>
on line
<b>1005</b>
<br/>
' ) });
</script>
<content:encoded>
<![CDATA[
<div id='wp_cta_2440_container' class='wp_cta_container
cta_outer_container'
style='margin-top:0px;margin-bottom:0px;position:relative;' ><div
id='wp_cta_2440_variation_0' class='inbound-cta-container wp_cta_content
wp_cta_variation wp_cta_2440_variation_0' style='overflow:
hidden;display:none; margin:auto; width: 300px; height: 400px;'
data-variation='0' data-cta-id='2440'><div id="blank-cta-template"> <div
style="background: blue;">Test</div> <div style="background: blue;"></div>
<div style="background-color: blue; text-align: center;
background-position: initial initial; background-repeat: initial
initial;"><a class="inbound-button inbound-special-class" href="Test"
target='_self' style="background-color: #c8232b; color: #ffffff;
font-size:20px;"><i class="fa- font-awesome fa"></i>Button Text</a></div>
</div> </div></div>
]]>
</content:encoded>
<wfw:commentRss>http://glocal.dev/blank-test/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
atwellpub commented 10 years ago

So cta 2240 is being rendered somehow. Any idea how/where?

DavidWells commented 10 years ago

Could it be because functions inside the class are not prefixed correctly?

DavidWells commented 10 years ago

shortcodes render in the rss feed as the raw html markup, same with the json call. But the constant is not defined. There is also the "headers being sent twice" error from the echo instead of return

atwellpub commented 10 years ago

Let's page up. So there is a shortcode rendering in an RSS feed? I'm just trying to understand what's going on.

The functions names in the class do not need any prefix. The class makes the function names private so it's actually cleaner and easier to read to not prefix the function names. This would not cause the problem.

The problem from what I can see so far is there is two errors:

Notice: Undefined property: CallsToAction::$disable_ajax in /Users/davidgregorywells/Dropbox/Sites/Local-Git/wp-content/plugins/cta/modules/module.calls-to-action.php on line 1008

Which should only throw if there is a shortcode rendering.

But I just added a fix that should quiet the error.

atwellpub commented 10 years ago

Next is this: https://github.com/inboundnow/cta/blob/master/modules/module.calls-to-action.php#L751-L765 and I may can solve this too. But still.... why is there a cta shortode rendering?

DavidWells commented 10 years ago

RSS feeds render full html content out of shortcodes. Same with the JSON API.

On Thu, Apr 10, 2014 at 12:58 PM, Hudson Atwell notifications@github.comwrote:

Next is this: https://github.com/inboundnow/cta/blob/master/modules/module.calls-to-action.php#L751-L765and I may can solve this too. But still.... why is there a cta shortode rendering?

Reply to this email directly or view it on GitHubhttps://github.com/inboundnow/cta/issues/29#issuecomment-40130844 .

atwellpub commented 10 years ago

Ok I just pushed the changes that should fix it. It turns load_custom_js_css function into an optional return or echo. And in the shortcode render function I'm catching the return and adding it onto the shortcode content return.

atwellpub commented 10 years ago

Needs testing to make sure nothing broke shortcode ctas or anything else.

DavidWells commented 10 years ago

just pulled and get Parse error: syntax error, unexpected 'public' (TPUBLIC) in /Users/davidgregorywells/Dropbox/Sites/Local-Git/wp-content/plugins/cta/modules/module.calls-to-action.php_ on line 780

On Thu, Apr 10, 2014 at 1:06 PM, Hudson Atwell notifications@github.comwrote:

Needs testing to make sure nothing broke shortcode ctas or anything else.

Reply to this email directly or view it on GitHubhttps://github.com/inboundnow/cta/issues/29#issuecomment-40131722 .

atwellpub commented 10 years ago

Closing due to inactivity.