LasseMT
Forum Replies Created
-
Forum: Plugins
In reply to: [CMB2] Sanitising multiple inputs in one field. (multidimensional array)Here is an updated pastebin. The metabox setup is in the bottom of the pastebin.
Forum: Plugins
In reply to: [CMB2] Sanitising multiple inputs in one field. (multidimensional array)Michael Beckwith Here is what I got for now in a pastebin: https://pastebin.com/bKE1jZv3. Currently my sanitize functions is empty because there have been no results in my different tries.
Btw, thank you again for taking a look on this! Do you have a donation link, where I can buy you a beer or two? ??
Forum: Plugins
In reply to: [CMB2] Sanitising multiple inputs in one field. (multidimensional array)Michael Beckwith Thank you for taking your time to help me, and I’m sorry I confused you with my bad explanation ??
It is something I need to do at that time of saving to the database. I might be of the chart by calling it “sanitization” (not sure if I have used the right word), but I want to make the array “clean” so it can be stored to the database.
The text inputs (not the checkbox) are saved when escape_cb and sanitization_cb is set to false. When I set escape_cb and sanitization_cb to true, I get the error message “Array to string conversion in https://www.example.dev/wordpress/wp-includes/formatting.php on line 1025”. Thats why I thought I needed to bypass the CMB sanitization methods with my own callback.
So I’m asking if someone could explain me how to handle an array like this:
array(2) { ["gluten"]=> array(2) { ["bool"]=> string(2) "on" ["type"]=> string(12) "Wheat gluten" } ["nuts"]=> array(2) { ["bool"]=> string(2) "on" ["type"]=> string(0) "" } }
in a custom sanitization callback. I will probably need to create a custom escaping callback as well.
Forum: Plugins
In reply to: [CMB2] Sanitising multiple inputs in one field. (multidimensional array)Thank you for you reply Justin ??
I don’t want to use repeatable fields, because I want the field to be static (not repeatable and the repeatable fields does not support checkbox. I used the custom field w/ multiple inputs to create my my custom field, but I need a way to sanitise my custom field.
I basically want to create something like this:
<ul> <li> <input type="checkbox" name="[gluten][bool]" id="gluten_bool" value="on" /> <input type="text" name="[gluten][type]" id="gluten_type" value="e.g. Wheat gluten" /> </li> <li> <input type="checkbox" name="[nuts][bool]" id="nuts_bool" value="on" /> <input type="text" name="[nuts][type]" id="nuts_type" value="e.g. Walnuts" /> </li> <li> And so on.. </li> </ul>
Where checkbox determine if the allergy should be outputted on front-page and the text input is the “NEW Value” that specifies the allergy more. So if the checkbox is checked and the text input has no value, it will output a standard value set for the allergy.
Here is an var_dump of an example $meta_value that is being sent to my custom cmb2_sanitize function:
array(2) { ["gluten"]=> array(2) { ["bool"]=> string(2) "on" ["type"]=> string(12) "Wheat gluten" } ["nuts"]=> array(2) { ["bool"]=> string(2) "on" ["type"]=> string(0) "" } }
How should I sanitise this information, so it can be saved with CMB2?
Forum: Fixing WordPress
In reply to: How to Make Embedded YouTube Videos ResponsiveI totally agree with wpismypuppet.
Forum: Fixing WordPress
In reply to: Create an "if mobile/table then echo" php for website.You should use css media queries for this.
You should create a button that is only displayed on tablets and phones. Look at the css below. Add the class “.hidden-desktop” to the button, and it will only show on tablets and phones. Then you shuould use javascript to show the content when this button is clicked.
.hidden-desktop { display: none !important; } // Phones only @media (max-width: 767px) { .hidden-desktop { display: inherit !important; } } // Tablets & small desktops only @media (min-width: 768px) and (max-width: 979px) { .hidden-desktop { display: inherit !important; } }
Forum: Fixing WordPress
In reply to: Where can I find??Usually you will find wp-config.php in the root folder. But I’m having a hard time understanding what your wp-config.php have to do with the “media uploader”.
Can you be more specific? I also think you should be more specific in the title of this thread..
Forum: Fixing WordPress
In reply to: Hard Crop Fails on Big Image sizes.Hi, sorry! It was only hidden characters that was the problem..
Forum: Fixing WordPress
In reply to: Add options to Custom Backgrounds.I found a soulution for this.
Read:
https://wordpress.stackexchange.com/questions/64652/how-do-i-add-settings-to-the-background-options-page
and:
https://codex.www.ads-software.com/Function_Reference/get_theme_modI hope this will help other people.
Tip:
You can use get_theme_mod when you are passing in variables from PHP with wp-less.Forum: Fixing WordPress
In reply to: Title on posts divided into pagesProblem solved.
Forum: Fixing WordPress
In reply to: Title on posts divided into pagesThank you alchymyth!
I used the global variables method because I used the variables earlier to show the pagination
echo 'Page '. $page .' of '. $numpages .'';
Forum: Fixing WordPress
In reply to: Hard Crop Fails on Big Image sizes.resolved it.
Forum: Fixing WordPress
In reply to: wp_nav_menu Add custom class to ul wrap?Thank you chandanonline4u! I just realized i was looking at the wrong code, so menu_class was already one of my args.
Forum: Themes and Templates
In reply to: Child Theme doesn't find Parent Theme.I am working locally at the moment. I have allready tried that, but it seams to be in the wordpress setup or something like that.
I am using wordpress with git, so i have made som modification to wp, s? i has pulled the wp-content out of the wordpress folder. So the content is separated from wordpress. I have used this setup for other projects, so i will try to just setup the project again. Thank you for your time ??
Forum: Themes and Templates
In reply to: Child Theme doesn't find Parent Theme.The code is different in the headers.
The child theme header is empty, but i just realized that the child theme is trying to include the headers from wordpress’s deafult theme twenty ten ect. but i have deleted twenty ten from the wp-content folder.
I am 100% sure about i have set the parent theme as the template inn the style.css for the child theme.