[BUSINESS] php... I'm stuck!
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
[BUSINESS] php... I'm stuck!
I slapped a little plugin together for displaying chaturbate WL cams using shortcode (with parameters) in pages or txt widgets. It works great except that the plugin content insists on displaying 1st in the content and above the widget title. I've scoured wordpress.org looking for a fix and I can't seem to figure out how to fix it. One suggestion I saw was to wrap the add_shortcode(... in add_action('init',... . Well it didn't work. I can use it as is but it's driving me batshit crazy. I've spent several days now screwing with it and I can't figure out wtf is doing this. Does anyone here have any suggestions on what I need to do to fix this? The plugin is running right now at https://nerdalert.site/cams/
The Fourth Turning Is Here
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
So, since you're using short codes, I'm going to guess that you're also using things like echo.
In WP fine print:
So, let's say there are echos in the shortcode, that will a lot of times cause WP to calculate those before the header.
To fix this, you have to make echos in the function variables, then return like "return $html;"
In WP fine print:
Code: Select all
Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. This is similar to the way filter functions should behave, in that they should not produce expected side effects from the call, since you cannot control when and where they are called from. To fix this, you have to make echos in the function variables, then return like "return $html;"
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
AHA!!! That's got to be it. There's a couple of echos. To brain dead to figure out how to correct this right now but I get what you're saying and it makes sense. CoolColmike7 wrote: ↑March 8th, 2019, 12:10 amSo, since you're using short codes, I'm going to guess that you're also using things like echo.
In WP fine print:So, let's say there are echos in the shortcode, that will a lot of times cause WP to calculate those before the header.Code: Select all
Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. This is similar to the way filter functions should behave, in that they should not produce expected side effects from the call, since you cannot control when and where they are called from.
To fix this, you have to make echos in the function variables, then return like "return $html;"
The Fourth Turning Is Here
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
By George that was it! I tried it and Widget title is now above. I guess I'll be cleaning out the rest of the echos. You're a life saver. I should have posted several days ago. Thanks!!!
The Fourth Turning Is Here
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
The Fourth Turning Is Here
- AlexO
- Verified Member

- Posts: 6396
- Joined: February 10th, 2018, 5:37 pm
- Title: I like Celebrities
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
You've got mail...
The Fourth Turning Is Here
-
STICK
- Verified Member

- Posts: 178
- Joined: February 25th, 2018, 7:28 am
Wher do you go to learn the simple stuff to be able to do your own php modifications to a page.
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
w3schools.com
The Fourth Turning Is Here
-
Colmike7
- Banned

- Posts: 1670
- Joined: May 23rd, 2018, 12:21 pm
- Title: (>^-^)b
Not really sure. But, making my first website when I was like 10 in the late 90s plus working with people from Chemical Abstracts on web design growing up and getting CISCO certified in web development in high school helped a lot. I never formally learned PHP, just learned by looking at things and looking up what I needed to know.
-
misterporn
- Verified Member

- Posts: 879
- Joined: May 24th, 2018, 4:21 pm
- HeidiHoe
- Verified Member

- Posts: 1653
- Joined: February 3rd, 2018, 12:20 pm
- Title: Resident Genius
lol
The Fourth Turning Is Here
-
minkal
- Verified Member

- Posts: 139
- Joined: October 2nd, 2018, 6:57 pm
One of the best places to learn