Richard Mišenčík

less info
49 reputation
19
bio website richardmisencik.com
location Slovakia
age 21
visits member for 10 months
seen Apr 29 at 15:27

Aug
27
awarded  Notable Question
Jun
27
awarded  Popular Question
Mar
25
awarded  Popular Question
Mar
17
awarded  Teacher
Feb
27
comment Warning: Illegal string offset on theme options page
@morganestes Thanks, In my question I have these 2 lines: $options[$id] = stripslashes($options[$id]); $options[$id] = esc_attr($options[$id]); which are esentially the same thing but stripslashes is added, is it needed or can i get rid of it and just use the esc_attr?
Feb
27
comment Warning: Illegal string offset on theme options page
Thanks, I already did this when I was trying and editing the code to get it to work, I also replaced the double quotes with single quotes just like your third example in the answer above. I also removed the esc_attr from register_setting, without that it now seems to work and I dont get that error now.
Feb
26
awarded  Tumbleweed
Feb
26
comment Warning: Illegal string offset on theme options page
@morganestes I updated my code and added an edit, please check that. I just didnt include my whole code so its not a big mess, the actual problem starts in the switch. Line 75 is the one with the first echo. And on this line Im getting the php warning.
Feb
26
revised Warning: Illegal string offset on theme options page
deleted 35 characters in body
Feb
26
comment Warning: Illegal string offset on theme options page
@BrianFegter I added the comment above the line, before it was after :) This is the line: echo "<input type='text' id='$id' name='" . 'rm_theme_options' . "[$id]' value='$options[$id]'>";
Feb
26
revised Warning: Illegal string offset on theme options page
Added comment before Line 75 and function to display the page
Feb
25
asked Warning: Illegal string offset on theme options page
Feb
23
comment Conditionally set post_content in wp_insert_post
Thanks for your answer and help, I learned something new. I chose the other answer as best because its simpler. But thanks, you described it all very well.
Feb
23
comment Conditionally set post_content in wp_insert_post
Yeah, its not going to be that much content anyway so no problem. Yeah it would be overkill. Yeah I probably should describe it better but basically its for when theme is activated I want to create default pages so the client doesnt have to do it manually and I dont need to assist them. Also in case the db would get deleted, that code would be ran again. I chose your answer as best, if it would be possible Id choose both of them as best.
Feb
23
accepted Conditionally set post_content in wp_insert_post
Feb
23
comment Conditionally set post_content in wp_insert_post
Thanks, the first example is more than enough, no need for nested arrays. The titles wont of course be that long, I was just wondering if they key in array can be uppercase, with spaces and characters like ťžýáí etc. And including seems like the way to go, or will it slow things down much? Also, what do you think about Shazzad's approach?
Feb
23
comment Conditionally set post_content in wp_insert_post
Thanks, this is another cool way, but which would be better? This or just creating an array like 'Home' => 'Content for home' by s_ha_dum.
Feb
22
comment Conditionally set post_content in wp_insert_post
Thanks this looks much simpler and cleaner, Im newbie in PHP so I had no idea how its best to do things like this. so it can be anything like 'Some long page title' => 'Content for some long page...'?
Feb
22
comment Conditionally set post_content in wp_insert_post
Well, for example, for home I dont need content because I use page template. But for others it will be a few paragraphs with the text for those pages. Im doing this so the client doesnt need to add that content when the page is deleted or on new install etc. Especially when it includes some HTML and they might not even be able to find the HTML tab in the editor.
Feb
22
comment Conditionally set post_content in wp_insert_post
@s_ha_dum Well something like, if(post_title == 'Home') { return ''; } elseif(post_title == 'About us') { return 'Some about us content...'; } elseif(post_title == 'Contact') {.....} etc. Would it be possible to put these conditions into a separate file so it doesnt get too messy?