Page 1 of 1

Custom Header Output?

PostPosted: May 4th, 2011, 7:59 pm
by AlxRam
I'm just getting started installing s2member and everything looks great. I'd like to hack the information that gets output to the header. I see two files (a css and javascript) associated with s2member and I only need them to show up on the single and page templates. I already have custom header templates for each.

So basically I'm looking for an example of how to:

1. Remove s2member css and javascript using functions.php
2. Then add s2member css and javascript to 2 template files only

I don't know if it's possible that way... any other suggestions would also be appreciated.

Thanks :)

Re: Custom Header Output?

PostPosted: May 4th, 2011, 8:02 pm
by AlxRam
Silly me. I just realized I can take the code from the source view and copy it to my template files. Now all I have to do is remove them using functions.php

I see the code example for removing the css:
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");

Can I use a similar action to remove the javascript file?

Re: Custom Header Output?

PostPosted: May 4th, 2011, 8:12 pm
by Cristián Lávaque
From the FAQs http://www.s2member.com/support/

How can I prevent s2Member Pro from loading it's default CSS?

You can place this into the functions.php file for your WordPress® theme.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
 


Or, you could remove only specific action Hooks; based on Payment Gateway.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_alipay_css_js::alipay_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_authnet_css_js::authnet_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_ccbill_css_js::ccbill_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_clickbank_css_js::clickbank_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_google_css_js::google_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_paypal_css_js::paypal_css");
 


I haven't tried it, but it's probable that it'll work for JavaScript if you change the css at the end for js. Let me know if it works. :)

Re: Custom Header Output?

PostPosted: May 4th, 2011, 8:23 pm
by AlxRam
Cristián Lávaque wrote:From the FAQs http://www.s2member.com/support/

How can I prevent s2Member Pro from loading it's default CSS?

You can place this into the functions.php file for your WordPress® theme.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
 


Or, you could remove only specific action Hooks; based on Payment Gateway.

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_alipay_css_js::alipay_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_authnet_css_js::authnet_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_ccbill_css_js::ccbill_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_clickbank_css_js::clickbank_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_google_css_js::google_css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_paypal_css_js::paypal_css");
 


I haven't tried it, but it's probable that it'll work for JavaScript if you change the css at the end for js. Let me know if it works. :)


Hmmm, strange. That code isn't removing either from the header. I'll keep playing with it some more and see if I can find the problem... this is what I put in functions.php

Code: Select all
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::js");


Also tried with apostrophes instead of quotes like this:

Code: Select all
remove_action ('ws_plugin__s2member_during_css', 'c_ws_plugin__s2member_pro_css_js::css');
remove_action ('ws_plugin__s2member_during_css', 'c_ws_plugin__s2member_pro_css_js::js');

Re: Custom Header Output?

PostPosted: May 4th, 2011, 10:05 pm
by Jason Caldwell
This will work, but you'll need to remove the Hooks, only after they've been added. Sorry, I should have included this in the documentation too. Please follow these updated instructions.

Create this directory and file:
/wp-content/mu-plugins/s2-hacks.php
Code: Select all
<?php
add_action 
("ws_plugin__s2member_after_loaded", "remove_s2_pro_css");
function remove_s2_pro_css ()
    {
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_css_js::css");
    }
?>
* This works for CSS only. You can't do this with s2Member's JS file, it would break Pro Form functionality and other areas of s2Member as well. The JavaScript library is required to operate s2Member.


If you'd like to ONLY remove the CSS for specific
Payment Gateway integrations, you can do it like this instead.
Code: Select all
<?php
add_action 
("ws_plugin__s2member_after_loaded", "remove_s2_pro_css");
function remove_s2_pro_css ()
    {
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_alipay_css_js::alipay_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_authnet_css_js::authnet_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_ccbill_css_js::ccbill_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_clickbank_css_js::clickbank_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_google_css_js::google_css");
        remove_action ("ws_plugin__s2member_during_css", "c_ws_plugin__s2member_pro_paypal_css_js::paypal_css");
    }
?>

@TODO: update the official documentation to make this clear.
100% Completed ( coming in the next release )

Re: Custom Header Output?

PostPosted: May 4th, 2011, 10:53 pm
by AlxRam
Odd. That plugin file isn't working either or I'm missing something with that. I uploaded it to /wp-content/mu-plugins/s2-hacks.php but there are no new plugins on my plugins page, and the header css is still there.

10-4 on the .js file being needed. I think I'll just leave both as-is as it's not crucial for me, I just like to run header info on the pages that need it only (as much as possible).

Thanks again for your help Jason :)