Build Your Own Business Website header image

Welcome to our Members Only Forum

You are welcome to view the content on our Forum, just scroll down to view this forum post.
If you like what you find and want to be able to post a question, please check out our subscription options.
Please feel free to search the forum using either the Google Site Search above or the forum search below.

Avatar
Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Adding JS and Php to wordpress pages
Avatar
Craig Grella
Pittsburgh, PA
Jedi
Members

Community Member
Forum Posts: 228
Member Since:
April 10, 2012
sp_UserOfflineSmall Offline
1
June 15, 2014 - 9:44 pm
sp_Permalink sp_Print

Rick,

 

I've got a client request and I'm not sure which way to go with it.

Client has financial calculators that are php files, made up of php and js.

There are 2 calculators, previously served up by 2 independent php files.

 

I'm wondering the best way to get them on the new wordpress site.

It's a woo theme, so I'm guessing i can wrap the existing pages with some woo templates and it will be okay, but I'm thinking it might be better to do with actual wordpress pages and then enqueue the scripts and inject the php with a function, but I'm not sure which way to go.

 

Any help or guidance you can give would be appreciated. Thanks.

 

Craig

Craig Grella

 

OrgSpring.com

Helping nonprofits harness the power of technology to build and maintain relationships

Facebook  |  Twitter  |  Google+

Avatar
Rick Anderson
Desert Hot Springs, CA
Admin
Forum Posts: 13637
Member Since:
November 8, 2009
sp_UserOfflineSmall Offline
2
June 16, 2014 - 3:22 pm
sp_Permalink sp_Print

I would probably turn the php into a  function and then add it to the pages via shortcode.

If the js is short I would simply insert it into the page with your function.  Even if it isn't short, if it shows up only on those pages then there is no benefit to enqueueing it.

Avatar
Craig Grella
Pittsburgh, PA
Jedi
Members

Community Member
Forum Posts: 228
Member Since:
April 10, 2012
sp_UserOfflineSmall Offline
3
June 16, 2014 - 8:03 pm
sp_Permalink sp_Print

I like the idea of leaving the page around because then they can add it to menus and see that it is in the page file structure. Thanks for that.

 

Any downside for making each calculator its own page template?

Craig Grella

 

OrgSpring.com

Helping nonprofits harness the power of technology to build and maintain relationships

Facebook  |  Twitter  |  Google+

Avatar
Rick Anderson
Desert Hot Springs, CA
Admin
Forum Posts: 13637
Member Since:
November 8, 2009
sp_UserOfflineSmall Offline
4
June 17, 2014 - 2:04 pm
sp_Permalink sp_Print

You would have to figure out the Woo template system.  Which is different that either Genesis or Thesis.  Otherwise, no - I don't see any reason why you couldn't do it as a template instead.

The upside of learning the woo system is that as I understand it, it is more similar to "the WordPress Way".  The downside is that it is one more thing to learn and master.

The shortcode solution - on the other hand would work with any theme regardless of its template structure or adherence to the WordPress way of doing things.

Avatar
Craig Grella
Pittsburgh, PA
Jedi
Members

Community Member
Forum Posts: 228
Member Since:
April 10, 2012
sp_UserOfflineSmall Offline
5
June 17, 2014 - 4:25 pm
sp_Permalink sp_Print

yes, i know woo well. probably better than thesis now.

And the template worked well, but i see your point about being theme agnostic. I'll have to put more thought into it.

Thanks again for the guidance.

Craig

Craig Grella

 

OrgSpring.com

Helping nonprofits harness the power of technology to build and maintain relationships

Facebook  |  Twitter  |  Google+

Avatar
Craig Grella
Pittsburgh, PA
Jedi
Members

Community Member
Forum Posts: 228
Member Since:
April 10, 2012
sp_UserOfflineSmall Offline
6
June 17, 2014 - 4:26 pm
sp_Permalink sp_Print

As a side note, the php is mostly functions. Can I nest functions in other functions and still use that as a shortcode?

Craig Grella

 

OrgSpring.com

Helping nonprofits harness the power of technology to build and maintain relationships

Facebook  |  Twitter  |  Google+

Avatar
Rick Anderson
Desert Hot Springs, CA
Admin
Forum Posts: 13637
Member Since:
November 8, 2009
sp_UserOfflineSmall Offline
7
June 18, 2014 - 8:16 am
sp_Permalink sp_Print

Sure.  The main trick to shortcodes is "returning" the output rather than "echoing" the output.  You can nest any number of functions and classes within the shortcode.

Forum Timezone: America/Los_Angeles

Most Users Ever Online: 228

Currently Online:
17 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Keith W Jones: 1441

Brian Tozer: 1004

Carolin: 984

Heidi Hafner: 509

John Cunningham: 423

Reece Morrel: 353

Newest Members:

soundpilot

digitalaerolus

emma62755

sharonmarks

emma80233

Tijs de Jong

Forum Stats:

Groups: 8

Forums: 46

Topics: 7003

Posts: 34845

 

Member Stats:

Guest Posters: 6

Members: 6763

Moderators: 2

Admins: 2

Administrators: Rick Anderson, Rick Anderson

Moderators: Pierre Cote, Laura Nugent